This query spans up a lot of paths, did you run it with PROFILE on your dataset?
Some suggestions: * you don't do anything with the first :SalesRelation is that intentional? if yes then move it to a where clause so it doesn't span up paths * your second match is NOT bound at all? is it is potentially gigantous * how many (sellerCompanyTopic:Company) are there? * and how many of these: > MATCH > (sellerCompanyTopic:Company)-[rel:Seller]->(sr:SalesRelation)-[rel2:Buyer]-(buyer:Company), > > sr<-[:PriceAgreement]-(contract:Contract) * perhaps you can reformulate your related somehow * an alternative would also be to do a UNION instead two of which would have rootTopic being the same as sellerCompanyTopic:Company or in the other case to buyer and only the third would have to look at related Any chance to get the database? > Am 05.10.2015 um 07:02 schrieb Ryan John Velasco <[email protected]>: > > How do you do CTE queries in neo4j? > > SAMPLE QUERY: > > MATCH (rootTopic:Company) WHERE rootTopic.ID = 172096 AND > (rootTopic)-[:Seller|Buyer]->(:SalesRelation) > MATCH > (sellerCompanyTopic:Company)-[rel:Seller]->(sr:SalesRelation)-[rel2:Buyer]-(buyer:Company), > > sr<-[:PriceAgreement]-(contract:Contract) > OPTIONAL MATCH p = shortestPath(rootTopic-[:Seller|Buyer*]-sellerCompanyTopic) > WITH DISTINCT rootTopic, sellerCompanyTopic, buyer, contract, > reduce( > index = 0, > type IN EXTRACT(r in relationships(p) | type(r))| > case > when index % 2 = 0 AND type = 'Buyer' > then -1000 > when index % 2 = 1 AND type = 'Seller' > then -1000 > ELSE index + 1 > END > ) AS Related > WHERE rootTopic = sellerCompanyTopic OR rootTopic = buyer OR Related > 0 > RETURN rootTopic.ID AS RootCompanyTopicID, sellerCompanyTopic.ID AS > SellerTopicID, buyer.ID AS BuyerTopicID, contract.ID AS ContractTopicID, case > when Related is null > then 1 > when Related < 0 > then 0 > ELSE Related > END AS Depth > ORDER BY RootCompanyTopicID, SellerTopicID, BuyerTopicID, ContractTopicID > > Best Regards, > Ryan > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
