javascript - Radius Based Search on lat,lon in AWS CloudSearch -
our company using aws cloudsearch search , retrieve user data.user data consists of field position of type lat,lon. given radius , position should find users in range of radius. how write search query retrieve required data ?
using node.js server side language .
please .
in cloudsearch not possible search latlons within radius. can order distance, can search within radius.
since want results within radius. instead create rectangle such it's 4 side touches circle want search in. now, can search inside bounding box rectangle , return results sorted distance.
the disadvantage there results on corners of bounding box, not in circle come in cloudsearch result. can either use approximation or filter further based on distance.
here example query same : q=user*&fq=location%3a%5b%2740.628611,-100.694152%27,%2725.621966,-66.686706%27%5d&expr.geo=haversin%2838.958687,-77.343149,location.latitude,location.longitude%29&sort=geo%20asc
here : fq=location%3a%5b%2740.628611,-100.694152%27,%2725.621966,-66.686706%27%5d ---> searches within bounding box latlons i.e. upper-left corner , lower right corner.
expr.geo=haversin%2838.958687,-77.343149,location.latitude,location.longitude%29&sort=geo%20asc ---> creates expression computes distance between latlon in search document fixed point(give center of circle). , returns result sorted distance.
note "haversin" distance function computes distance between latlons distance between 2 points on perfect sphere.
Comments
Post a Comment