What is the difference between multiple MATCH clauses and a comma in a Cypher query?

后端 未结 5 731
死守一世寂寞
死守一世寂寞 2021-02-01 02:43

In a Cypher query language for Neo4j, what is the difference between one MATCH clause immediately following another like this:

MATCH (d:Document{document_ID:2})
         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 03:02

    In a more generic way, "The same relationship cannot be returned more than once in the same result record." [see 1.5. Cypher Result Uniqueness in the Cypher manual]

    Both MATCH-after-MATCH, and single MATCH with comma-separated pattern should logically return a Cartesian product. Except, for comma-separated pattern, we must exclude those records for which we already added the relationship(s).

    In Andy's answer, this is why we excluded repetitions of the same movie in the second case: because the second expression from each single MATCH was using there the same :WROTE relationship as the first expression.

提交回复
热议问题