ElasticSearch -- use distance from point to affect query relevance

distance, elasticsearch, geolocation

Solution

You can use `distance` function in the script of the Custom Score Query to modify `_score` based on the distance from a centerpoint.

Problem

Trying to use ElasticSearch to create a search that uses distance from a centerpoint to influence relevance. I don't want to simply sort on distance from a point, which I know is possible, because I want relevance based on the searched query to also affect results. I'd like to pass in a search string, say "coffee", and a lat/lon, say "38, -77", and get my results ordered by a combination of how related they are to "coffee" and how close they are to "38, -77". Thanks!

Original source