[英]How to cypher query a neo4j DB with WHERE clause on sparse property
I have Nodes in my Neo4j database that have certain properties that do not exist on all nodes, but I want to query against those properties with Cypher with a WHERE clause. 我的Neo4j数据库中有一些节点,这些节点具有并非在所有节点上都存在的某些属性,但是我想使用带有WHERE子句的Cypher查询这些属性。
Example Data: 示例数据:
{id:"52", name:"Jim", age:"32", gender:"M"}
{id:"55", name:"Lisa", age:"22", gender:"F"}
{id:"97", name:"Chris", age:"38"}
Now, if I want to run a Cypher query on gender, it gives me an error on the Chris record, stating that the gender property does not exist on that node. 现在,如果我要对性别运行Cypher查询,它将在Chris记录上给我一个错误,指出该节点上不存在性别属性。
Example Cypher query: Cypher查询示例:
START n=NODE(*) WHERE n.gender="M" RETURN n;
The specific error message I am getting is: 我收到的特定错误消息是:
EntityNotFoundException: The property 'gender' does not exist on Node[4925]
I am running version 1.9.2 of Neo4j. 我正在运行Neo4j的1.9.2版本。 I'd like to upgrade to 2.x and try to use labels and auto_indexes galore. 我想升级到2.x并尝试使用标签和大量的auto_indexes。 But, I'm not in a position go move away from the stable release yet. 但是,我还不能离开稳定版本。
Any way to solve this with Cypher query, or with 1.9.2 indexing features? 用Cypher查询或1.9.2索引功能解决此问题的任何方法?
You can do: 你可以做:
WHERE n.gender! = "M"
or 要么
WHERE has(n.gender) AND n.gender = "M"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.