I am executing the following two queries and i am getting some result.
First query
START
person=node:NODE_TYPE(NODE_TYPE='PERSON')
MATCH
(person)-[?:contacts]->(var1)-[?:addresses]->(var2)-[?:details]->(var3)-[?:items]->(var4)-[?:items]->(var5)-[?:value]->(var6)
WHERE
var2.`#nodeId` ='at0000' and var3.`#nodeId` ='at0001' and var4.`#nodeId` ='at0002' and var5.`#nodeId` ='at0028' and var6.`value` =~'address.*'
return distinct person;
Second query
START
person=node:NODE_TYPE(NODE_TYPE='PERSON')
MATCH
(person)-[?:contacts]->(var1)-[?:addresses]->(var2)-[?:details]->(var3)-[?:items]->(var4)-[?:value]->(var5)
WHERE
var2.`#nodeId` ='at0000' and var3.`#nodeId` ='at0001' and var4.`#nodeId` ='at0009' and var5.`value` =~'india.*'
return distinct person;
But when I combine the two queries to a single query to get persons that match both these conditions, it isn't working.
the combined query is
START
person=node:NODE_TYPE(NODE_TYPE='PERSON')
MATCH
(person)-[?:contacts]->(var1)-[?:addresses]->(var2)-[?:details]->(var3)-[?:items]->(var4)-[?:items]->(var5)-[?:value]->(var6) , (person)-[?:contacts]->(var7)-[?:addresses]->(var8)-[?:details]->(var9)-[?:items]->(var10)-[?:value]->(var11)
WHERE
var2.`#nodeId` ='at0000' and var3.`#nodeId` ='at0001' and var4.`#nodeId` ='at0002' and var5.`#nodeId` ='at0028' and var6.`value` =~'address.*' and
var8.`#nodeId` ='at0000' and var9.`#nodeId` ='at0001' and var10.`#nodeId` ='at0009' and var11.`value` =~'india.*'
return distinct person;
This query return an empty iterator.
I used 'comma' to combine the MATCH conditions and 'and' to combine the WHERE conditions. Is there any problem in this?
(I am implementing a query builder to build cypher query. I have to check multiple condition matches. What is the best way to do this?)
Neo4j 1.9M04
person
s that meet both of these criteria? That is, are there anyperson
s that appear in the result of query 1 and query 2? – ean5533