Can we set GEO filters for distance search using Yii2-Sphinx?

211 Views Asked by At

I am using Yii2-sphinx extension and everything working fine. Now I am doing distance search using sphinx so i want to set latitude and longitude for a given postcode. How can I set those two filters for my index?

As sphinx has an option to set geofilters but in yii2-sphinx, I am not able to do this.

1

There are 1 best solutions below

3
On

See, http://sphinxsearch.com/blog/2013/07/02/geo-distances-with-sphinx/

Want a query somewhat like

SELECT *, GEODIST(0.659298124, -2.136602399, latitude, longitude) as distance 
  FROM geodemo WHERE distance < 10000 ORDER BY distance ASC LIMIT 0,100;

So would need to use GEODIST function in ->select() and the filter in ->andWhere()

May want to change the order too.