简体   繁体   中英

find all nodes with a given label and property using the neo4j java API

I know about the findNodesByLabelAndProperty method of the GraphDatabaseServiceObject, but that method requires a value parameter. In my case, I only want to know if there are any (1 or more) nodes in my database that have a specified label and property, but I don't know anything about the value of the property other than it's type. Any ideas?

Thanks Howard

If you are using version 2.0 you could use the method getAllNodesWithLabel from class org.neo4j.tooling.GlobalGraphOperations.

GlobalGraphOperations.getAllNodesWithLabel(DynamicLabel.label("<label_name>"))

For more information: http://neo4j.com/api_docs//2.0.0-M06/org/neo4j/tooling/GlobalGraphOperations.html#getAllNodesWithLabel(org.neo4j.graphdb.Label)

不确定我是否正确理解了这个问题,但是我只是创建另一个(布尔值)属性来查找节点。

You can create another node to store these kinds of counts- a single one with multiple properties such as "nodesWithLabelXAndPropertyY" with the count as the value which you can set at the end of your algorithm run. Or just a boolean exists/not exists value. Then all you need to do is query this node for summary statistics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM