Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this Neo4j.query not returning results when using Neo4j::Rails::Model when cypher does?
    primarykey
    data
    text
    <p>I am trying to do a simple test with Neo4j.rb using Neo4j::Rails::Models thats tag a single thing, then performs a query to find the thing again using the tag.</p> <p>So data is essentially looks like this, with a single tag and a single thing:</p> <p>(tag)-tags->(thing)</p> <p>When I run the query using my script I don't get any results but if I use the webadmin console that comes with neo4j to run the equivalent query I get result as execpted.</p> <p>I just can't figure out what I am doing wrong but I think it must be the way I am using the Neo4j.query block.</p> <p>This is what I run from the console which gives the correct result.</p> <pre><code>neo4j-sh (0)$ START tag=node:Tag_exact(text='tag') MATCH tag-[:tags]-&gt;thing RETURN thing; ==&gt; +------------------------------------------+ ==&gt; | thing | ==&gt; +------------------------------------------+ ==&gt; | Node[1]{name:"thing",_classname:"Thing"} | ==&gt; +------------------------------------------+ ==&gt; 1 row ==&gt; 197 ms ==&gt; neo4j-sh (0)$ </code></pre> <p>This is the test script which gives an equivalent cypher query but doesn't return any results.</p> <pre><code>require 'rubygems' require 'neo4j' require 'fileutils' # Create a new database each time Neo4j::Config[:storage_path] = "test_neo" FileUtils.rm_rf(Neo4j::Config[:storage_path]) # Models class Tag &lt; Neo4j::Rails::Model property :text, :index =&gt; :exact end class Thing &lt; Neo4j::Rails::Model property :name end # Data thing = Thing.new(:name =&gt; "thing") thing.save tag = Tag.new(:text =&gt; "tag") tag.outgoing(:tags) &lt;&lt; thing tag.save # Query puts Neo4j::Cypher.query { lookup("Tag_exact", "text", "tag").outgoing(:tags).as(:thing) }.to_s # START v1=node:Tag_exact(text="tag") MATCH (v1)-[:`tags`]-&gt;(thing) RETURN thing results = Neo4j.query do lookup("Tag_exact", "text", "tag").outgoing(:tags).as(:thing) end results.each do |result| p result["thing"] end # nil, I want to get the name of thing back here </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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