Home » Php » php – Solr vs. Sphinx for spatial search

php – Solr vs. Sphinx for spatial search

Posted by: admin July 12, 2020 Leave a comment


I’m tasked with choosing the fulltext search engine we’re going to be using on an upcoming projects. Based on what I’ve read, I’m leaning toward Solr, but I’m a little concerned about spatial search. In addition to some other parameters (keywords, category, etc.) we want to be able to specify a location and a maximum distance (e.g., within 25 miles of Tempe, AZ). We’d like to be able to sort the results by distance.

Spatial SOLR is apparently pretty new, and it’s not entirely clear what its maturity is. There are also a couple of other options (manually calculating and then inverting the distance, or solr-spatial-light.

My question is basically: is Spatial Solr (or solr-spatial-light) ready enough for primetime to handle the case I described above, or are we better off going with Sphinx?

I’d also be interested in hearing general experiences implementing either of these, particularly with php.

How to&Answers:

I’m currently using Spatial Search Plugin (SSP) for Apache Solr in production, which is based on
an older implementation of spatial Solr. The new spatial implementation is (as of this writing) available only in trunk (or nightly builds) and currently being implemented. I’m not aware of the current state of this implementation.

While Spatial Plugin has some minor issues and this older code is less flexible than the current implementation, it has the advantage of being easily deployable to an existing stable Solr 1.4 instance. Plus, it’s well documented. I’m using it for the exact same use-case you describe without any problems or performance issues.

You will need some geocoder to convert the locations to latitude/longitude coordinates. You can use MaxMind’s GeoLite City or any other location database.

I can’t comment on Sphinx as I don’t use it.