如何使用地理位置过滤通配符查询的结果?我的查询看起来像这样
{
"query": {
"bool" : {
"should": [
{
"wildcard": {
"title": {
"value": "*football*"
}
}
},
{
"wildcard": {
"description": {
"value": "*football*"
}
}
}
],
"filter" : {
"geo_distance" : {
"distance" : "90km",
"geolocation" : "45.50, 40.10"
}
}
}
}
}
但是查询总是按geo_distance返回结果,例如跳过通配符。我只想返回距离最大为90公里,但标题或说明中包含“足球”的结果。
答案 0 :(得分:0)
您需要做的就是在查询中添加minimum_should_match: 1
:
{
"query": {
"bool" : {
"minimum_should_match": 1, <-- add this
"should": [
{
"wildcard": {
"title": {
"value": "*football*"
}
}
},
{
"wildcard": {
"description": {
"value": "*football*"
}
}
}
],
"filter" : {
"geo_distance" : {
"distance" : "90km",
"geolocation" : "45.50, 40.10"
}
}
}
}
}