is it possible to provide some filter or query that allows me to boost on
geo-distance?
i.e. if there is a document with a location that is within 100km i want to
boost it to the top. if it isn't within the range, i don't want to boost it
at all.
is it possible to provide some filter or query that allows me to boost on
geo-distance?
i.e. if there is a document with a location that is within 100km i want to
boost it to the top. if it isn't within the range, i don't want to boost it
at all.
I think you achieve it by combining Custom Filters Score Query
(http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html)
with Geo Distance Filter
(Elasticsearch Platform — Find real-time answers at scale | Elastic)
On Monday, April 16, 2012 10:32:39 AM UTC-4, Peter Schröder wrote:
is it possible to provide some filter or query that allows me to boost on
geo-distance?i.e. if there is a document with a location that is within 100km i want to
boost it to the top. if it isn't within the range, i don't want to boost it
at all.
yeah, had the same idea.
this kinda works:
{
"query": {
"custom_filters_score": {
"query": {
"match_all": {}
},
"filters": [
{
"filter": {
"geo_distance_range": {
"from": "0km",
"to": "100km",
"location": {
"lat": "47.16104233",
"lon": "8.42149815"
}
}
},
"boost": "3"
}
],
"score_mode": "first"
}
},
"filter": {
"term": {
"ck_names": "software"
}
}
}
but this gives me an error:
{
"query": {
"term": {
"ck_names": "software"
},
"custom_filters_score": {
"query": {
"match_all": {}
},
"filters": [
{
"filter": {
"geo_distance_range": {
"from": "0km",
"to": "100km",
"location": {
"lat": "47.16104233",
"lon": "8.42149815"
}
}
},
"boost": "3"
}
],
"score_mode": "first"
}
}
}
Caused by: org.elasticsearch.search.SearchParseException:
[development-companies-v3.8.1-218-gf575086-2012-04-02-112352][0]:
query[ConstantScore(NotDeleted(:))],from[-1],size[-1]: Parse Failure [No
parser for element [filters]]
In the second case you cannot have two queries: "term" and
"custom_filter_score" queries on the same level. If you want the term query
to affect the score just replace match_all with term.
On Monday, April 16, 2012 12:12:46 PM UTC-4, Peter Schröder wrote:
yeah, had the same idea.
this kinda works:
{
"query": {
"custom_filters_score": {
"query": {
"match_all": {}
},
"filters": [
{
"filter": {
"geo_distance_range": {
"from": "0km",
"to": "100km",
"location": {
"lat": "47.16104233",
"lon": "8.42149815"
}
}
},
"boost": "3"
}
],
"score_mode": "first"
}
},
"filter": {
"term": {
"ck_names": "software"
}
}
}but this gives me an error:
{
"query": {
"term": {
"ck_names": "software"
},
"custom_filters_score": {
"query": {
"match_all": {}
},
"filters": [
{
"filter": {
"geo_distance_range": {
"from": "0km",
"to": "100km",
"location": {
"lat": "47.16104233",
"lon": "8.42149815"
}
}
},
"boost": "3"
}
],
"score_mode": "first"
}
}
}Caused by: org.elasticsearch.search.SearchParseException:
[development-companies-v3.8.1-218-gf575086-2012-04-02-112352][0]:
query[ConstantScore(NotDeleted(:))],from[-1],size[-1]: Parse Failure [No
parser for element [filters]]
d'oh!
© 2020. All Rights Reserved - Elasticsearch
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.