title: Cypher dynamic queries for neo4j? How can I achieve that?
body: <p>I'm trying to make dynamically building cypher query with python. I have a list of dicts, that contains pair of Node name and Node value. I need to filter Node:Goods by related Node:Property. Let's say that <strong>one</strong> Node:Goods has <strong>many</strong> Node:Property, and I need to filter :Goods by :Property name and value. For example I need all :Goods that has a relation with :Property <code>{name: "Color", value: "blue"}</code> and another :Property <code>{name: "Material", value: "Oak"}</code> . For that case I figure out query like this: </p>
  
  <p><code>MATCH (g:Goods) 
  WHERE EXISTS( (g)-[:PROP]-(:Property {name: "Color", value: "blue"})) 
  AND EXISTS( (g)-[:PROP]-(:Property {name: "Material", value: "Oak"}))
  RETURN g</code></p>
  
  <p>Python gets list of dicts and for each dict makes string <code>EXISTS( (g)-[:PROP]-(:Property {name: %s, value: %s}))</code>. It works perfectly, but what if I need to make compare between some properties? For example - price range? I cant assign a variable for Node:Property inside <code>EXISTS()</code>, also I cant use <code>WHERE</code> inside other <code>WHERE</code> statement. How can I query all :Goods with :Property <code>{name: "Color", value: "blue"}</code> and another :Property <code>{name: "Price", value: "&gt; 190, &lt;320"}</code> ? There is no problem to pass to query any arguments or build it dynamically from list of dicts, there is problem with my Cypher knowledge :). Please help! </p>