1
我有三个以下参数,我将通过运行查询,它们是;弹性搜索我如何查询多个匹配或功能
- 查询 - 无论是地方名称,描述或空,
- LAT - 一个地方或空的任纬度,
- LON - 任的经度放置或空
基于上述参数,我根据query
得分查询items
列表,然后计算result
和lat, lon
之间的距离。
现在,我有以下脚本来获得基于query
和distance
的items
;
{
"query": {
"function_score": {
"query": {
"bool": {
"must": [{
"multi_match" : {
"query": "Lippo",
"fields": [ "name^6", "city^5", "country^4", "position^3", "address_line^2", "description"]
}
}]
}
},
"functions": [
{
"gauss": {
"position": {
"origin": "-6.184652, 106.7518749",
"offset": "2km",
"scale": "10km",
"decay": 0.33
}
}
}
]
}
}
}
但事实是,如果query
是空的,不会有结果的。我想要的是,结果是基于query
或distance
。
无论如何要实现这一目标吗?任何建议表示赞赏。
这样做对我来说..但是,我终于打消了我的'functions'检查距离。我最终使用了简单的'query'和'filter'。谢谢 – choz
你也可以发布^^这个版本。 – kaulmonish