Neo4j Spatial 'WithinDistance' Cypher query returns empty while REST call returns data -


i have appears correctly configured spatial layer , index , can query node using findgeometrieswithindistance rest api call.

post /db/data/ext/spatialplugin/graphdb/findgeometrieswithindistance {"layer":"geom","pointx":15.0,"pointy":60.0,"distanceinkm":100.0} 

however, when querying using cypher, no results (i have tried reversing order of 60.0 , 15.0 without luck):

start n=node:geom('withindistance:[60.0, 15.0, 500.0]') return n; 

cyper returns:

==> +---+ ==> | n | ==> +---+ ==> +---+ ==> 0 row ==>  ==> 13 ms 

rest:

200 ok ==> [ { ==>   "paged_traverse" : "http://localhost:7474/db/data/node/14472/paged/traverse/{returntype}{?pagesize,leasetime}", ==>   "outgoing_relationships" : "http://localhost:7474/db/data/node/14472/relationships/out", ==>   "data" : { ==>     "lon" : 15.2, ==>     "bbox" : [ 15.2, 60.1, 15.2, 60.1 ], ==>     "racename" : "parador es muy caliente", ==>     "lat" : 60.1, ==>     "gtype" : 1 ==>   }, ==>   "all_typed_relationships" : "http://localhost:7474/db/data/node/14472/relationships/all/{-list|&|types}", ==>   "traverse" : "http://localhost:7474/db/data/node/14472/traverse/{returntype}", ==>   "self" : "http://localhost:7474/db/data/node/14472", ==>   "all_relationships" : "http://localhost:7474/db/data/node/14472/relationships/all", ==>   "property" : "http://localhost:7474/db/data/node/14472/properties/{key}", ==>   "properties" : "http://localhost:7474/db/data/node/14472/properties", ==>   "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/14472/relationships/out/{-list|&|types}", ==>   "incoming_relationships" : "http://localhost:7474/db/data/node/14472/relationships/in", ==>   "incoming_typed_relationships" : "http://localhost:7474/db/data/node/14472/relationships/in/{-list|&|types}", ==>   "extensions" : { ==>   }, ==>   "create_relationship" : "http://localhost:7474/db/data/node/14472/relationships" ==> } ] 

rest calls reproduce: create layer:

post /db/data/ext/spatialplugin/graphdb/addsimplepointlayer { "layer":"geom", "lat":"lat", "lon":"lon" } 

create index:

post /db/data/index/node/ {"name":"geom", "config":{"provider":"spatial", "geometry_type":"point","lat":"lat","lon":"lon"}} 

create node:

post /db/data/node {"lat":60.2,"lon":15.1,"racename":"parador es muy caliente"} 

(in response, examine "self" , find nodeid)

index node:

post /db/data/ext/spatialplugin/graphdb/addnodetolayer {"layer":"geom", "node":"http://localhost:7474/db/data/node/###new_node_id###"} 

find:

post /db/data/ext/spatialplugin/graphdb/findgeometrieswithindistance {"layer":"geom","pointx":15.0,"pointy":60.0,"distanceinkm":100.0} 

i investigated this, , related issue have seen few times. there inconsistency in design of spatial library in there 2 ways add node spatial index. 1 add layer (using addnodetolayer rest call), , uses underlying java api directly connects node rtree part of same graph. other create proxy node in index graph domain graph not connected index graph. second approach taken indexprovider interface (using /db/data/index/node/geom rest call).

if call both methods, node added twice, once directly , once proxy. problem cypher withindistance index query accesses indexprovider interface, , return nodes not connected index. if add node in both ways, not returned.

so need add 1 of 2 ways. did not see in original email mention of addnodetolayer, suspect sdn might calling addnodetolayer (perhaps michael can comment), in case cannot use cypher call.

during testing, able manually remove 1 index relationship using cypher this:

start n=node(13065) match (n)<-[r:rtree_reference]-() delete r

replace number 13065 node id original node.

i did following in neo4j browser (in 2.1.2):

:post /db/data/ext/spatialplugin/graphdb/addsimplepointlayer { "layer":"geom", "lat":"lat", "lon":"lon" } :post /db/data/index/node/ {"name":"geom", "config":{"provider":"spatial", "geometry_type":"point","lat":"lat","lon":"lon"}} :post /db/data/node {"lat":60.2,"lon":15.1,"racename":"parador es muy caliente"} :post /db/data/index/node/geom {"value":"dummy","key":"dummy", "uri":"http://localhost:7474/db/data/node/13071"} 

this created graph node not directly connect index. in case rest call 'findgeometrieswithindistance' not work (uses standard java api), while cypher 'withindistance' work. tested command:

start n = node:geom("withindistance:[60.2,15.1,100.0]") return n 

note unfortunately api puts order lat,lon, instead of more standard lon,lat.

then added layer (ie. add directly index graph):

:post /db/data/ext/spatialplugin/graphdb/addnodetolayer {"layer":"geom", "node":"http://localhost:7474/db/data/node/13071"} 

now when search cypher command still same correct answer, when search rest command:

:post /db/data/ext/spatialplugin/graphdb/findgeometrieswithindistance {"layer":"geom","pointx":15.0,"pointy":60.0,"distanceinkm":100.0} 

i find returns proxy node instead of original node.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -