cypher - Neo4j: Why are paths of length 0 not returned? -
imagine simple scenario company has products, , data:
(c:company {name: 'uber'})-[:has_product]->(p:product {name: 'uber app'})
i expect query
match (c:company)-[:has_product*0..1]->(p:product) return c.name, p.name;
to return
uber, null uber, uber app
since path can of length 0. however, returns only
uber, uber app
am misunderstanding how paths work in neo4j?
i think confusing how 0 length match works. 0 length relationship hop match start node itself. in query though end node in path specifies :product
label. since first node has :company
label query never yield 0 length match. if try following query without label specified on end node should return few rows: 1 'uber' in both columns , other 'uber' in 1 column , other column had product 'uber app'.
match (c:company {name: 'uber'})-[*0..1]->(p) return c.name, p.name;
Comments
Post a Comment