简体   繁体   English

使用neo4j Java API查找具有给定标签和属性的所有节点

[英]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. 我知道GraphDatabaseServiceObject的findNodesByLabelAndProperty方法,但是该方法需要一个值参数。 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. 就我而言,我只想知道数据库中是否有(1个或更多)具有指定标签和属性的节点,但是除了属性的类型外,我对属性的值一无所知。 Any ideas? 有任何想法吗?

Thanks Howard 谢谢霍华德

If you are using version 2.0 you could use the method getAllNodesWithLabel from class org.neo4j.tooling.GlobalGraphOperations. 如果使用的是2.0版,则可以使用类org.neo4j.tooling.GlobalGraphOperations中的getAllNodesWithLabel方法。

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) 有关更多信息: 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. 您可以创建另一个节点来存储这些类型的计数-具有多个属性的单个节点,例如“ nodesWithLabelXAndPropertyY”,其计数可以在算法运行结束时设置。 Or just a boolean exists/not exists value. 或者只是一个布尔值存在/不存在值。 Then all you need to do is query this node for summary statistics. 然后,您要做的就是查询此节点的摘要统计信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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