Last active

Embed URL


SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#### SETUP
# 1.) Create a simple point layer
curl -X POST -d '{"layer":"geom","lat":"lat","lon":"lon"}' --header "Content-Type:application/json" http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer
# 2.) Add a spatial index
curl -X POST -d '{"name":"geom","config":{"provider":"spatial","geometry_type":"point","lat":"lat","lon":"lon"}}' --header "Content-Type:application/json" http://localhost:7474/db/data/index/node/
# 3.) Create a sample node with lat and lon data (you can change the name of the properties in step 2)
curl -v -X POST -d '{"query":"CREATE (n {name:\"Strandbar Hermann 2\",lon:16.385539770126344,lat:48.21198395790515}) RETURN n;"}' --header "Content-Type:application/json" http://localhost:7474/db/data/cypher
# 4.) Add this node to the previously created "geom" index (step 2)
# This should be done by an auto indexer:
curl -X POST -d '{"key":"name","value":"Strandbar Hermann 2","uri":"http://localhost:7575/db/data/node/5"}' --header "Content-Type:application/json" http://localhost:7474/db/data/index/node/geom
# 5.) Add the node to the PointLayer (This is not necessary. Adding it to the spatial index will handle this too)
#curl -X POST -d '{"layer":"geom","node":"http://localhost:7575/db/data/node/5"}' --header "Content-Type:application/json" http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer
# 6.) Get nodes within distance via REST API
curl -v -X POST -d '{"layer":"geom","pointX":16.3,"pointY":48.2,"distanceInKm":100.0}' --header "Content-Type:application/json" http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance
## Returns the "Strandbar Hermann" node
# 7.) Get nodes within Distance via cypher
curl -X POST -d "{\"query\":\"START node=node:geom('withinDistance:[48.2,16.3,100.0]') return node\"}" --header "Content-Type:application/json" http://lcalhost:7474/db/data/cypher
## Returns the "Strandbar Hermann" node

There's an error in step 4)

For me it was node/4 and needs to be 7474

curl -X POST -d '{"key":"name","value":"Strandbar Hermann 2","uri":"http://localhost:7474/db/data/node/4"}' --header "Content-Type:application/json" http://localhost:7474/db/data/index/node/geom

Thanks for posting ! I too would like to index directly from cypher

Have you found a solution to this issue? besides manually hitting the rest api to add to index?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.