How to search records between two coordinates usin

2020-08-01 05:13发布

问题:

I have a start lat long and an ending lat long and I have to search other records between these points using solr spatialSearch. Thanks in advance if anyone can help me.

Best Records...

Aisha Zafar

回答1:

You can use Solr's Bounding-box filter to find the records between the box but it works with single point (lat,lon) and a distance.

If you have two points then you can find the record between this box by using range query. Query could be something like :

..&fq=latField:[lat1 TO lat2] AND lonField:[lon1 TO lon2]



回答2:

This is the solr query: just change the pt as a search coordinate and the distance d as a radius of a circle. fq={!geofilt sfield=coordinates}&pt=10.737845823323038,106.65631819042972&d=2.8'

each document which is indexed from solr with this schema.xml config:

< field name="coordinates" type="geohash" indexed="true" stored="true" multiValued="true" />

and document object should contain a field like this: $fields['coordinates'] = implode(',', $post->getCoordinates()->getLatLng());



标签: solr