Spatial Indexing in Neo4j
Posted By : Abhay Garg | 30-Mar-2015
Hello ,
Neo4j Spatial is a library facilitating the import, storage and querying of spatial data in the Neo4j open source graph database
Query Neo4j spatial in Neo4j Console -> If you get this error
No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.
by running this Query
START user=node:userLocations(withinDistance:[78.0,29.0,3.45]')return user
then you need to add Neo4j Library in Neo4j lib folder
Download neo4j-spatial-0.13-neo4j-2.1.6-server-plugin.zip , extract it and paste all jars into lib folder inside neo4j-community-2.1.7
Now run this Query again
START user=node:userLocations(withinDistance:[78.0,29.0,3.45]')return user
, and now error might change , but you did not see this error
No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.
If you did not see this error then Neo4j is ready to do Spatial Indexing
Runnign Neo4j Spatial Indexing in Grails Project
Add mavenRepo in BuildConfig.groovy inside repositories{}
mavenRepo "https://raw.githubusercontent.com/neo4j-contrib/m2/master/releases"
Add Dependency in BuildConfig.groovy inside dependencies {}
compile "org.neo4j:neo4j-spatial:0.13-neo4j-2.1.6"
Add
@NodeEntity
class UserDomain {
@Indexed(indexType = IndexType.POINT, indexName = userLocations)
Point wkt
}
in User.groovy Domain
make sure that Location os user should be named as wkt
while saving user
user.wkt= =new Point(lat,lon)
Now you find user as per the Locations
START user=node:userLocations(withinDistance:[78.0,29.0,3.45]')return user
For more information https://github.com/neo4j-contrib/spatial
or email : [email protected]
THANKS
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Abhay Garg
Abhay is a Grails Developer expertise in OptaPlanner and Angular js framework.