I want to boost the score of records that are close to some geo position.
Elastic has filters for geo, but that just includes or excludes records.
Is there a way to manipulate the score using the distance? I know there
is a custom_score query where I could specify something like "script" : "_score
doc['my_numeric_field'].value". The question is, how would I use the
distance in the calculation, and not the value of the numeric field?
You can calculate the distance using the following
expression: doc['your_geo_field'].distanceInKm(lat, lon) and then use it to
figure out the boost factor. For example this script: "_score *
(doc['your_geo_field'].distanceInKm(40, -70) < 100 : 2.0: 1.0)" will apply
boost 2.0 to all records that are located within 100km from the location
(40, -70). Alternatively, you can use Custom Filters Score Queryhttp://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.htmlto boost records using a geo_distance filter. So, a faster equivalent of
the above expression would be:
On Thursday, December 20, 2012 4:17:34 PM UTC-5, Mike wrote:
I want to boost the score of records that are close to some geo position.
Elastic has filters for geo, but that just includes or excludes records.
Is there a way to manipulate the score using the distance? I know there
is a custom_score query where I could specify something like "script" : "_score
doc['my_numeric_field'].value". The question is, how would I use the
distance in the calculation, and not the value of the numeric field?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.