4
尝试创建一个搜索,它将带回距离某个地理点约500m的位置结果。带过滤器的ElasticSearch function_score查询
我需要根据源位置是否为空来过滤来自此搜索的结果。
我试过这样的事情:
"filtered" : {
"filter": {
"missing" : { "field" : "location" }
}
}
这是搜索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
}
}
}]
}
}
}
我试图把过滤器在不同的地方查询,但它并没有为工作我,所以我知道我正在做一些根本上错误的查询结构。将来我想添加更多的评分逻辑和其他过滤器,但是找不到这样的查询的一个好例子。
我应该怎么做才能使它工作?