neo4j find all nodes with matching properties

后端 未结 7 2063
走了就别回头了
走了就别回头了 2020-12-30 04:15

I have a relatively large set of nodes, and I want to find all pairs of nodes that have matching property values, but I don\'t know or care in advance what the property valu

7条回答
  •  醉酒成梦
    2020-12-30 04:37

    What about the following approach:

    • use getAllNodes to get an Iterable over all nodes.
    • using getPropertyKeys and getProperty(key) build up a java.util.Map containing all properties for a node. Calculate the map's hashCode()
    • build up a global Map using the hashCode as key and a set of node.getId() as values

    This should give you the candidates for being duplicate. Be aware of the hashCode() semantics, there might be nodes with different properties mapping to the same hashCode.

提交回复
热议问题