How to check array property in neo4j?

浪尽此生 提交于 2019-12-07 02:28:37

问题


How to search node using cypher query where one of the node property having array of string ?
e.g. members-- > ["abc","xyz","pqr"].
I can find the node by keeping order of array elements in same manner, for e.g.

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

but How to search node if I do not / cannot provide the exact order of elements as they are in node property ?


回答1:


Use the "all" predicate to ensure every element in the root.member is in the given list, i.e. root.members is a subset of the given list, and the length expression ensures that the given list has no more elements than what is in the root.members, so both of them contain the exactly same 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


来源:https://stackoverflow.com/questions/19118956/how-to-check-array-property-in-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!