如何在neo4j中检查数组属性?

时间:2013-10-01 14:33:09

标签: neo4j cypher spring-data-neo4j

如何使用cypher查询搜索节点,其中一个节点属性具有字符串数组?
例如members-- > ["abc","xyz","pqr"]
我可以通过以相同的方式保持数组元素的顺序来找到节点,例如,

START root=node(*) where has(root.members) and root.members=["abc","xyz","pqr"] return root;

但如果我不能/不能提供节点属性中元素的确切顺序,如何搜索节点?

1 个答案:

答案 0 :(得分:9)

使用“all”谓词来确保root.member中的每个元素都在给定列表中,即root.members是给定列表的子集,而length表达式确保给定列表的元素不超过给定列表的子集。 root.members中的内容,因此它们都包含完全相同的成员。

START root=node(*)
Where has(root.members) and all ( m in root.members where m in ["abc","xyz","pqr"]) and length(root.members) = length(["abc","xyz","pqr"])
Return root