0

How to write complex queries involving search in multiple Node types. for example following query returns ids of products usually bought together.

match (n:Product)-[:CONTAIN]-(:Order)-[:CONTAIN]-(p2:Product)
where ID(n)={product_id}
return ID(p2), count(*) as bought_count

But I am not able to figure out how to do such queries using Neomodel Node objects. any help?

context: I have two nodes name order and product. each order node is linked to all products it contains with relation named contain. Now I want to query all products which shares same order bucket.

Learner
  • 81
  • 1
  • 5
  • Could you provide more information or the context maybe ? – rbcvl Feb 12 '21 at 15:10
  • I tried to make it more clear. Let me know if anything which can make it clearer. – Learner Feb 15 '21 at 05:38
  • 1
    The short answer is don't, use a raw cypher query for this as it'll be faster and will ensure that you run what is required. If you wanted to then use models afterwards, which it appears you don't in this case, you would then use the inflate method to populate the model. So my suggestion would be to create a custom method on your product class that runs this cypher – Steve Mapes Apr 19 '21 at 13:12

0 Answers0