我正在使用带有bool / must / filter的elasticsearch,并使用geo_distance
过滤器进行过滤。以下是一些示例查询:
curl -XPOST 'localhost:9200/indexname/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"bool" : {
"must": {
"term": { "name": "cafe" }
},
"filter": {
"geo_distance" : {
"distance" : "20km",
"pin.coordinates" : {
"lat" : 13.9291040000,
"lon" : -70.8269250000
}
}
}
}
}
}
对于上述查询,我至少得到1个或更多结果。
如果我使用should
以及上述查询,则不显示任何匹配/结果
curl -XPOST 'localhost:9200/indexname/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"bool" : {
"must": {
"term": { "name": "cafe" }
},
"filter": {
"geo_distance" : {
"distance" : "20km",
"pin.coordinates" : {
"lat" : 13.9291040000,
"lon" : -70.8269250000
}
}
},
"should" : [
{ "term" : { "category_ol" : "cafe" } },
{ "term" : { "name_en" : "cafe" } }
],
"minimum_should_match" : 1,
"boost" : 1.0
}
}
}
有任何解决方案吗?
TIA