neo4j vs mongodb for spatial search
Asked Answered
Z

4

11

I'm getting ready to start a project where I will be building a recommendation engine for restaurants. I have been waffling between neo4j (graph db) and mongodb (document db). my nodes/documents will be things like restaurant and person. i know i will want some edges, something like person->likes->restaurant, or person->ate_at->restaurant. my main query, however, will be to find restaurants within X miles of location Y.

if i have 20 restaurant's within X miles of Y, but not connected by any edges, how will neo4j be able to handle the spatial query? i know with mongodb i can index on lat/long and query all restaurant types. does neo4j offer the same functionality in a disconnected graph?

when it comes to answering questions like, 'which restaurants do my friends eat at most often?', is neo4j (graph db) the way to go? or will mongodb (document db) provide me similar functionality?

Zellers answered 7/3, 2012 at 16:22 Comment(0)
A
7

I'm not that familiar with Neo4J Spatial but it would seem that MongoDB is at the very least a good fit since it's the database Foursquare uses with exactly the purpose you describe. MongoDB geo indexing is extremely fast and scales up nicely.

Ashwin answered 7/3, 2012 at 16:57 Comment(2)
Agreed, don't look any further. MongoDB is a perfect match for your requirements. Now just mix it with Node.JS and you have an ultra-fast and scalable solutionPearle
thanks guys - i now plan on implementing mongodb for this solution, which is what i initially wanted to do because of the spatial indexing and numerous APIs.Zellers
W
11

Neo4j Spatial introduces a Spatial RTree (or other means) index that is part of the graph itself. That means, even disconnected domain entities will be found via the spatial search, if you index them (that is relationships will connect the Spatial index to the Restaurants). Also, this is flexible enough that you can combine the Raw BBox search in the RTree with other things like check on the restaurants categories in the same go, since you can hop out and in the different parts of the graph.

This way, neo4j Spatial is supporting the full range of search capabilities that you would expect form a full Topology, like combined searches and searches on polygons with holes etc.

Be aware that Neo4j Spatial is in 0.7, so be gentle and ask on http://groups.google.com/group/neo4j/about :)

Whitsun answered 8/3, 2012 at 8:28 Comment(0)
A
7

I'm not that familiar with Neo4J Spatial but it would seem that MongoDB is at the very least a good fit since it's the database Foursquare uses with exactly the purpose you describe. MongoDB geo indexing is extremely fast and scales up nicely.

Ashwin answered 7/3, 2012 at 16:57 Comment(2)
Agreed, don't look any further. MongoDB is a perfect match for your requirements. Now just mix it with Node.JS and you have an ultra-fast and scalable solutionPearle
thanks guys - i now plan on implementing mongodb for this solution, which is what i initially wanted to do because of the spatial indexing and numerous APIs.Zellers
M
1

Another possible solution is to use CouchBase. It uses a document model as well - though you need to be much more comfortable with MapReduce for queries. It has better spatial capabilities right now thank MongoDB but that may change over time.

Suggestion aside, I agree that of the two choices you have given Mongo will suit your needs fine and probably more appropriate for your spatial queries.

Metamorphic answered 18/4, 2012 at 16:22 Comment(0)
B
0

Neo4j geospatial doesn't scale up that good. I created a geospatial layer in neo4j and added nodes to this layer. Beyond 10,000 nodes the addition of nodes to the layer becomes very slow even when using neo4j2.0

On the other hand, mongodb geo-location works comparatively much faster and is more scalable.

Burget answered 21/1, 2014 at 6:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.