Skip to content
ponceta edited this page Nov 28, 2014 · 2 revisions

SphinxSearch doesn't have much support for geo referenced searching out of the box.

That's the only native support. It allows to filter and sort results according to the distance to a certain point. GeoAnchor needs lon/lat coordinates (in decimal minutes) in the indexes as attributes.

The idea is to put lon/lat inside the indexes using the centroid coordinate. Something like: x(st_transform(st_centroid(the_geom),4326)) as lon y(st_transform(st_centroid(the_geom),4326)) as lat

This is not implemented and tested yet

Quadindex

We are using a quadindex for geo referneced searching. The quadindices are calculated with the bounding boxes of each geometry, resulting in a string with up to 21 characters e.g. "021213212321". For searching, we will search with ^021* to find all geometries which quadindices start with 021. It makes no sense to search in the middle of a quadindex.

Quadindex are imprecise in that they return false positives (objects with are not in a bounding box's quadindex specified). But when we combine quadindex with GeoAnchor above, we can sort the results according the GeoAnchor and probably improve the results significantly (this still needs to be tested)

Improving GeoSearch on sphinx

Here is a nice example of an attempt to improve sphinx response time to spatial queries (for which it is initially not designed for!) http://nerds.airbnb.com/how-we-improved-search-performance-by-2x/

Clone this wiki locally