数据库的映射是这样的:ElasticSearch 2桶水平整理
{
"users": {
"mappings": {
"user": {
"properties": {
credentials": {
"type": "nested",
"properties": {
"achievement_id": {
"type": "string"
},
"percentage_completion": {
"type": "integer"
}
}
},
"current_location": {
"type": "geo_point"
},
"locations": {
"type": "geo_point"
}
}
}
}
}
现在在映射,你可以看到有两个地理距离场的一个是CURRENT_LOCATION和其他的位置。现在我想根据credentials.percentage_completion对用户进行排序,这是一个嵌套字段。这项工作很好,例如该查询, 实例查询:
GET /users/user/_search?size=23
{
"sort": [
{
"credentials.percentage_completion": {
"order": "desc",
"missing": "_last"
}
},
"_score"
],
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "100000000km",
"user.locations": {
"lat": 19.77,
"lon": 73
}
}
}
}
}
}
我想改变排列顺序制作成桶,所需的顺序是先全部显示谁在user.current_location的100KM半径和整理他们的人根据凭证.percentage_completion,然后其余的用户通过credentials.percentage_completion重新排序。
我试图在条件排序,并使其成为多层次,但不会工作,因为只有嵌套可以有过滤器和嵌套字段只有子级。
我以为我可以使用_score进行排序,并给予1000公里以下的人更多的相关性,但地理距离是一个过滤器,我似乎没有找到任何方法来给过滤器的相关性。
有什么我在这里失踪,任何帮助将是伟大的。
感谢