我需要做的是按位置提升文档(越近越好)。locations
是嵌套类型。
工作正常,但如果文档中缺少 Elasticsearch 不返回locations
文档。如果缺少字段,Elasticsearch 应该将文档视为完美命中。知道如何实现这一目标吗?
我的查询:
{
"sort": [
{
"_score": "desc"
}
],
"query": {
"function_score": {
"query": {
"bool": {
"must_not": [],
"should": [
{
"nested": {
"path": "locations",
"query": {
"function_score": {
"score_mode": "sum",
"functions": [
{
"gauss": {
"locations.coordinates": {
"origin": {
"lat": "50.1078852",
"lon": "15.0385376"
},
"scale": "100km",
"offset": "20km",
"decay": "0.5"
}
}
}
]
}
}
}
}
]
}
}
}
}
}
顺便说一句:我正在使用 Elasticsearch 5.0