David González
David González

Reputation: 39

Neo4j Spatial work for POST but not work cypher

I have used Neo4j 3.0.4 + Spatial.

I am working with curl, and I have make this calls:

addSimplePointLayer,(create nodes),addNodeToLayer

In this point, I try:

findGeometriesWithinDistance

And work perfectly (I have need change lat,lon by lon,lat...)

But I need use in cypher, for example:

START n=node:geom('withinDistance:[40.39742917035895,-3.495200140744832, 100.0]') 
  WITH n 
  WHERE n:TypeX
  RETURN n;

This never return results because "geom" is empty. I haven't any index, I try to create a new index with provider "spatial", and not work (i have read that is option was remove).

Can I put all nodes of TypeX in geom index?, or Can I use withinDistance without index? (I think in where is not posible use this)

Upvotes: 0

Views: 111

Answers (1)

William Lyon
William Lyon

Reputation: 8546

The index provider has been removed in the spatial extension for Neo4j 3.x in favor of using procedures. Instead you can call the procedures directly from Cypher. For example:

To create a SimplePointLayer:

CALL spatial.addPointLayer("geom")

Then to add Restaurant nodes to the layer:

MATCH (r:Restaurant) WITH collect(r) AS restaurants
CALL spatial.addNodes("geom", restaurants) YIELD node
RETURN count(*)

Then to perform a within distance query:

CALL spatial.withinDistance("geom",{latitude: 40.39742917035895,longitude:-3.495200140744832}, 100.0) YIELD node AS restaurant
RETURN restaurant

Documentation for these procedures is still in progress, but there is some documentation on the Github project README and in this post.

Upvotes: 0

Related Questions