neo4jrb / neo4jrb_spatial

Basic integration between Neo4j.rb and Neo4j Spatial
12 stars 12 forks source link

Spacial match throwing error - Neo4j::Session::CypherError: org.apache.lucene.queryParser.ParseException: Cannot parse 'withinDistance #1

Closed payalgupta closed 9 years ago

payalgupta commented 9 years ago

Hello,

I have used neo4j gem and neo4jrb_spatial ruby library in my application. The modal looks as:

class Eatery include Neo4j::ActiveNode include Neo4j::ActiveNode::Spatial

spatial_index 'eateries' property :lat property :lon ...

A dummy eatery in the database looks like this: eatery = Eatery uuid: "1dc225f1-0c74-499c-a9c4-0499becc50c0", budget_for_2: nil, lat: 60.1, lon: 15.2, name: "Chris's Restauarant", sid: 2, smugglr_score: 0, zomato_score: 3.0

added eatery node to spacial index

eatery.add_to_spatial_index

searching for spacial matches

Neo4j::Session.current.query.start('n = node:eateries({location})').params(location: 'withinDistance:[15.2,60.1,100.0]').pluck(:n) # lon/lat are same as above

Above throws an error : Neo4j::Session::CypherError: org.apache.lucene.queryParser.ParseException: Cannot parse 'withinDistance:[15.2,60.1,100.0]': Encountered " "]" "] "" at line 1, column 31. Was expecting one of: "TO" ...

... ... Any help will be appreciated. Thanks, Payal
maxdemarzi commented 9 years ago

Looks like it has a Lucene Index not a Spatial Index... can you verify the spatial index was created and you don't have a lucene index by the same name? See http://maxdemarzi.com/2014/01/31/neo4j-spatial-part-1/ for looking at spatial internal nodes.

payalgupta commented 9 years ago

@maxdemarzi Thanks for your reply. Yes, i dont see any spatial index getting created. If I try to manually create a spacial index Neo4j::Session.current.create_spatial_index('restaurants')

it fails and says: No index provider 'spatial' found. It seems to be installation issue. Do I need to install something additional for spatial?

maxdemarzi commented 9 years ago

Yes, you need the spatial plugin installed. See https://github.com/neo4j-contrib/spatial#using-the-neo4j-spatial-server-plugin for instructions.

payalgupta commented 9 years ago

@maxdemarzi Thanks.
Feeling embarrassed :( for my stupidity. First hack it then read it :dancer:

maxdemarzi commented 9 years ago

No worries, not your fault. That Readme file is like 1000 pages long, nobody reads it, plus install should be the first thing. Once you get it working, maybe you can contribute a quick "TLDR" section to the readme at the top.

payalgupta commented 9 years ago

@maxdemarzi Yes, will get it working and then add a section for reference.

payalgupta commented 9 years ago

@maxdemarzi Wow! Finally got some results upon searching using spatial query :) Have updated the README and submitted pull request for the same.

Thanks for your prompt help.