Use a distance_feature query when matching documents should remain eligible but receive higher relevance scores as their date or geographic-point values approach an origin. A pivot distance controls the distance scale used for the boost; it does not define a filtering radius. section 12.0 section 12.9.1
Configure the query with these core choices:
- Set field to a date, date_nanos, or geo_point field. section 12.9.1
- Set origin to the reference date or geographic point. section 12.9.1
Prioritize universities near London Bridge
After mapping location as geo_point, search with: GET universities/_search { "query": { "distance_feature": { "field": "location", "origin": [-0.0860, 51.5048], "pivot": "10 km" } } } The query boosts universities closer to the specified origin, allowing nearby results to appear higher in relevance order.
Prefer iPhones near a release date
Combine a name match with a date preference: match iPhones containing “12”, then use a distance_feature should clause with release_date, origin 1-12-2020, and pivot 30 d. The returned iPhone 12 Mini scores above iPhone 12 because its release date is closer to the origin.
