I am following this link to search and sort by geo location.
It seems to be sorting fine, but i want the distance measured as part of return results.
This line in the guide clearly says i can specify distance in return field -
You can include the distance calculated for each document in the search
results by specifying the name of the expression with the return parameter.
For example, return=distance.
This is my params object:
var params = {
queryParser: 'simple', /* simple | structured | lucene | dismax' */
query: q, /* required */
size: 30,
expr : '{"distance":"haversin(' + loc[0] + ',' + loc[1] + ',loc.latitude,loc.longitude)"}',
sort : 'distance asc',
return : "distance"
};
But in results, i am not seeing distance in the "fields" array
{
"status":{"rid":"pardxe0paQr1OzQ=","timems":44},
"hits":{"found":2,"start": 0,"hit":
[{"id":"4yaBBW15"},
{"id":"VydvXtl9"}]
}
PS: I am using AWS-SDK for NodeJS/Javascript
Aucun commentaire:
Enregistrer un commentaire