Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I agree with tstorms about indexing and execution of cypher queries. I would point out, however, that node identifiers are ephemeral. They are useful within a limited time window, but then are recycled. So, a node will not necessarily have the same identifier over multiple executions (or once the garbage collector has run).</p> <p>Generally, in Neo4J, if you need to query nodes by properties (and not through traversal), you create an index. For example, you could create an index named "actors":</p> <pre><code>IndexManager index = graphDb.index(); Index&lt;Node&gt; actors = index.forNodes( "actors" ); </code></pre> <p>If the index does not exist, this command will create it. Otherwise, it returns the existing index.</p> <p>However, unlike SQL, in Neo4J you must manually add the node to the index:</p> <pre><code>Node reeves = graphDb.createNode(); reeves.setProperty( "name", "Keanu Reeves" ); actors.add( reeves, "name", reeves.getProperty( "name" ) ); </code></pre> <p>You can then query the index for <em>all</em> nodes that match the specified query (indices do not guarantee uniqueness):</p> <pre><code>IndexHits&lt;Node&gt; hits = actors.get( "name", "Keanu Reeves" ); Node reeves = hits.getSingle(); </code></pre> <p>Source: <a href="http://docs.neo4j.org/chunked/milestone/indexing-create.html">http://docs.neo4j.org/chunked/milestone/indexing-create.html</a></p> <p>Note that Neo4J indices don't actually read properties from the node, you must explicitly tell it how to index the node. You could provide an arbitrary piece of information on which to index that isn't stored on the node, but I wouldn't recommend it.</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