1

I am having some problems with my neo4j rails project. I am trying to get a query to work, but I keep getting Index 'node_auto_index' does not exist. I have found this link that appears to solve this if you were running a separate neo4j server. However I am not, I am using the neo4j.rb gem which fixes all this for me, so there is no neo4j.properties file anywhere.

I though the neo4j.properties were mirrored in the config/application.rb, but when I try to do config.neo4j.node_auto_indexing = true it does not help.

The cypher query I am trying to do is done like this:

@q = Neo4j._query("CYPHER 1.9 START n=node:node_auto_index('name:*{query}*') 
                  MATCH (n)-[r:CONNECTED*0..6]-(tag) 
                  RETURN reduce(sum = 1, ni IN r: sum * ni.price) LIMIT 6", 'query' => params[:query])
#I have tried with and without the "CYPHER 1.9" part.

How can I solve this? Is there a lucene way of doing the same kind of request? Note the use of reduce which is important.

Is there a way to get the node_auto_index to work in Neo4j.rb?

Any help would be greatly appriciated!


Versions:

  • jRuby 1.7.4
  • gem 'rails', '3.2.14'
  • gem 'neo4j', '2.3.0-java'
Community
  • 1
  • 1
Automatico
  • 12,420
  • 9
  • 82
  • 110

1 Answers1

0

You have to initialize your autoindex before you can query it. If your db isn't too big, try running this:

start n=node(*) 
set n.name=n.name;

Also, I noticed you're multiplying the prices in the reduce--looks like you're calculating a sum, so you probably want to use the + operator.

Eve Freeman
  • 32,467
  • 4
  • 86
  • 101
  • I am having some issues with this. I am getting `property name does not exist on Node[0]`. When adding `where id(n) <> 0`, I get the same issue for `Node[1]`. Any idea how to fix this? And, yeah, the multiplication is right. I am not doing sum per say, I am doing some stuff with these weights. – Automatico Sep 22 '13 at 13:15
  • Yeah, you probably need to check whether the property exists. `start n=node(*) where has(n.name) set n.name=n.name;` – Eve Freeman Sep 22 '13 at 15:17
  • This does not help with the `node_auto_index` unfortunately. – Automatico Sep 22 '13 at 16:07
  • you also need to set the keys that you are indexing in the auto index in the initial config. – Eve Freeman Sep 22 '13 at 17:12