问题
I was playing around with the select for querying the index. I wanted to return a distance for a GeographyPoint I have in the index. I was trying something like this: where GeoPoint is the location field
$select=ID,geo.distance(GeoPoint, geography'POINT(-122.131577 47.678581)')
Is there a way to return distance in a Select statement if you have the lat and long and the location?
Thanks!
回答1:
Azure Search does not currently support returning the result of geo.distance
in the search response. Please vote for the feature on User Voice to help us prioritize.
As a workaround, you can calculate the distance yourself. This forum thread and this answer describe a few ways to do this.
回答2:
Even I wished it would work
But you cannot directly get the distance by using 'select'. It is currently enabled only as a filter and orderby property.
'SELECT' can be used only on the field names
来源:https://stackoverflow.com/questions/51484560/return-value-from-geo-distance-function-in-a-select-query