neo4j find all nodes with matching properties

后端 未结 7 2032
走了就别回头了
走了就别回头了 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:52

    Cypher to count values on a property, returning a collection of nodes as well:

    start n=node(*)
    where has(n.prop)
    with n.prop as prop, collect(n) as nodelist, count(*) as count
    where count > 1
    return prop, nodelist, count;
    

    Example on console: http://console.neo4j.org/r/k2s7aa

    You can also do an index scan with the property like so (to avoid looking at nodes that don't have this property):
    start n=node:node_auto_index('prop:*') ...

    2.0 Cypher with a label Label:

    match (n:Label)
    with n.prop as prop, collect(n) as nodelist, count(*) as count
    where count > 1
    return prop, nodelist, count;
    

    Update for 3.x: has was replaced by exists.

    0 讨论(0)
提交回复
热议问题