尝试创建一个搜索,该搜索将返回距离某个地理位置约500米的位置结果.
我需要根据源中的位置是否为空来过滤此搜索的结果.
我尝试过这样的事情:
"filtered" : {
"filter": {
"missing" : { "field" : "location" }
}
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的搜索JSON:
{"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"match": {"fieldA": "value"}
},
{
"match": { "fieldB": "value"}
}
]
}
},
"functions": [{
"gauss": {
"location": {
"origin": "'.$lat.','.$lon.'",
"scale": "500m",
"offset": "0km",
"decay": 0.33
}
}
}]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试将过滤器放在查询的不同位置,但它对我不起作用,所以我知道我正在做一些从根本上错误的查询结构.在将来我想添加更多的评分逻辑和其他过滤器,但找不到这样的查询的好例子.
我该怎么做才能让它发挥作用?