Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在cypher neo4j中正确执行OR条件_Neo4j_Cypher - Fatal编程技术网

如何在cypher neo4j中正确执行OR条件

如何在cypher neo4j中正确执行OR条件,neo4j,cypher,Neo4j,Cypher,我正在用neo4j做一个交友网站,我正在努力寻找匹配查询 WITH COLLECT(DISTINCT other) as to_exclude MATCH (other:user) WHERE 'man' IN other.interest AND NOT other.email = 'some.email@gmail.com' AND other:man OR other:woman AND 'man' IN other.interest AND NOT other.email = 'so

我正在用neo4j做一个交友网站,我正在努力寻找匹配查询

WITH  COLLECT(DISTINCT other) as to_exclude
MATCH (other:user) WHERE 'man' IN other.interest AND NOT other.email = 'some.email@gmail.com' AND other:man OR other:woman AND 'man' IN other.interest AND NOT other.email  = 'some.email@gmail.com'
WITH to_exclude, COLLECT(DISTINCT other) AS result  
WITH [elem IN result WHERE NOT elem IN to_exclude | elem] AS final_result
UNWIND final_result AS to_return
RETURN to_return
但这是一个可怕的问题,因为或迫使我重复我自己

一开始,我做了一些类似于
的事情,其中other:man或other:woman和…
,但似乎OR组的第一部分不受我的其他条件的影响

所以我不得不重复一遍
条件1和条件2或条件3和条件1

我想要一些更实用、更容易阅读的东西

出于某种原因,For
似乎没有针对Cypher的文档。但是,使用我们可以看出
的优先级高于

因此,查询中的这个子句(重新格式化以显示有趣的模式):

可简化为该等效条款:

WHERE
  (other:man OR other:woman) AND 'man' IN other.interest AND NOT other.email = 'some.email@gmail.com'

你能分享一下你对这个查询的期望吗?也许你可以用括号将你的逻辑操作分组,向我们展示你的意图?我知道实际上没有关于它的文档。我发布这个问题只是为了让人们意识到这一点。因为它应该有更多的文档记录。堆栈溢出比我最初发现它的方式更实用。(继续官方neo4j的懈怠,问这样的问题感到愚蠢)
WHERE
  (other:man OR other:woman) AND 'man' IN other.interest AND NOT other.email = 'some.email@gmail.com'