Note that there are some explanatory texts on larger screens.

plurals
  1. PONeo4J Cypher Match by multiple relationship types - strange behavior
    text
    copied!<p>My graph looks like this</p> <p>medium-[:firstChapter]->chapter1-[:nextChapter]->chapter2_to_N</p> <p>there is only one node connected via :firstChapter and then several nodes may follow, connected via :nextChapter</p> <p>I tried to match all nodes that are either connected via relationship :firstChapter to medium or connected via :nextChapter from one chapter to another</p> <p>The query I tried looks like this</p> <pre><code>start n=node(543) match n-[:firstChapter|nextChapter*]-&gt;m return m; </code></pre> <p>node(543) is the node medium. Surprisingly, this query returns all nodes in the path, even though the nodes are not connected to n (=medium node) If I leave out the * sign after nextChapter, only the first node with the :firstChapter relationship is returned (chapter1), which seems to be correct.</p> <pre><code>start n=node(543) match n-[:firstChapter|nextChapter*]-&gt;m return m; </code></pre> <p>Why does the query above return nodes <strong>not connected to n</strong>? As far as I understand it, the * sign usually returns nodes that are an unlimited number of relationships away, right?</p> <p>What is the best way to match all nodes of a path (only once) that are either connected via :firstChapter or :nextChapter to a start node? In this case all chapters</p> <p>The query above serves that purpose, but I don't think the output is correct...</p> <p>EDIT: Added a diagramm to clarify. As you can see, the first chapter may only be reached via :firstChapter, So it is still unclear, why the query above returns ALL chapter nodes <img src="https://i.stack.imgur.com/ncuhc.png" alt="Graph Diagram"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload