如何使用稀疏属性上的WHERE子句来密码查询neo4j DB [英] How to cypher query a neo4j DB with WHERE clause on sparse property
问题描述
我的Neo4j数据库中有一些节点,这些节点具有并非在所有节点上都存在的某些属性,但是我想使用带有WHERE子句的Cypher查询这些属性.
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.
示例数据:
{id:"52", name:"Jim", age:"32", gender:"M"}
{id:"55", name:"Lisa", age:"22", gender:"F"}
{id:"97", name:"Chris", age:"38"}
现在,如果我想对性别运行Cypher查询,它将在Chris记录上给我一个错误,指出该节点上不存在性别属性.
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查询示例:
Example Cypher query:
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]
我正在运行Neo4j的1.9.2版本.我想升级到2.x并尝试使用gallery和auto_indexes.但是,我还不能离开稳定版本.
I am running version 1.9.2 of Neo4j. I'd like to upgrade to 2.x and try to use labels and auto_indexes galore. But, I'm not in a position go move away from the stable release yet.
有什么方法可以通过Cypher查询或1.9.2索引功能解决此问题?
Any way to solve this with Cypher query, or with 1.9.2 indexing features?
推荐答案
您可以这样做:
WHERE n.gender! = "M"
或
WHERE has(n.gender) AND n.gender = "M"
这篇关于如何使用稀疏属性上的WHERE子句来密码查询neo4j DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!