Spatial Queries using Cypher

75 views
Skip to first unread message

Alireza Rezaei Mahdiraji

unread,
Oct 17, 2014, 6:14:55 AM10/17/14
to ne...@googlegroups.com

Hi All,

I would like to know how much of spatial neo4j queries are expressible using Cypher?
Is there any documentation of this?

Thanks,
Alireza

Craig Taverner

unread,
Oct 17, 2014, 9:02:22 AM10/17/14
to ne...@googlegroups.com
Hi Alireza,

Right now there is only one option, the IndexProvider implementation, which allows you to view the spatial index as an index in cypher, and access it using the 'START n=node:A(B)' syntax, where 'A' is your index name and 'B' contains your query. This only allows a limited set of possible queries.

Interestingly one of the best descriptions of this support was given by Jim Biard in Stack Overflow at http://stackoverflow.com/questions/24548819/neo4j-spatial-contain-search. I welcome to you read through that.

Our own plans to add spatial functionality to Cypher will be quite different, based more on the newer 'Schema Index' approach in 2.x, and allowing spatial functions in the cypher predicates themselves (in the WHERE clauses). This should be more intuitive, but ill not be available for some time. This support will be part of an official neo4j release and as such have documentation included in the normal neo4j documentation.

The documentation for the older spatial library is a bit scattered unfortunately. And I think Jim's answer looked like a particularly comprehensive answer to me.

Regards, Craig

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alireza Rezaei Mahdiraji

unread,
May 23, 2015, 12:04:03 PM5/23/15
to ne...@googlegroups.com

Hi Craig,

I am wondering if there is any new development regarding cypher supporting spatial queries.

Thanks,
Alireza

Craig Taverner

unread,
May 24, 2015, 8:20:23 AM5/24/15
to ne...@googlegroups.com
Hi Alireza,

Yes and no. Yes, there has been progress within Neo4j, but no there is nothing public to show for it yet, and it is not yet in the schedule for releases. I'm hoping it is not too far off, but cannot commit to anything specific yet. Once we have something more concrete to share, we'll do so.

If you have some specific use cases you'd like to discuss, feel free to contact me and we can discuss how they align with the current plans.

Regards, Craig

Alireza Rezaei Mahdiraji

unread,
May 24, 2015, 1:00:51 PM5/24/15
to ne...@googlegroups.com

Hi Craig,

Some of use cases are as follows:

1- Given a set of nodes with polygon geometry, find in which polygon a given point coordinates is located in

2- Given a set of nodes with geometry type point, find all nodes which thier distance to a given point
coordinate is less than a given radius r

3- Given a set of nodes with geometry type point, which are located in a bounding box,

4- Given a set of nodes with geometry type point, find  k nodes closest to a given point geometry (knn)

Thanks,
Best,
Alireza

Craig Taverner

unread,
May 24, 2015, 1:29:21 PM5/24/15
to ne...@googlegroups.com
Hi Alireza,

Use cases 2, 3 and 4 are covered by the current plans and should be available in the first release, as long as the points coordinates are in wgs-84. Use case 1 will not be supported in the first release, as polygons will not be possible to store or index initially. This, as well as other coordinate systems are being considered for later releases.

Of course, these plans could change.

One thing about point 4. It be supported indirectly through the use of a distance search (use case 2) combined with an order by and limit.

Regards, Craig

Alireza Rezaei Mahdiraji

unread,
May 24, 2015, 5:55:54 PM5/24/15
to ne...@googlegroups.com

Hi Craig,

Just to clarify, do you mean that it is not possible to them right now and should wait till next realease of Neo4j, right?

If yes, when would that be?

Best,
Alireza 
Reply all
Reply to author
Forward
0 new messages