Elasticsearch combine bool/filter 查询
Elastic search combine bool/filter Query
我正在尝试在同一个查询中搜索两个点,如下所示。
但结果返回空。
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": [{
"geo_shape": {
"border": {
"shape": {
"type": "point",
"coordinates": [longitude1, latitude1]
},
"relation": "intersects"
}
}
}, {
"geo_shape": {
"border": {
"shape": {
"type": "point",
"coordinates": [longitude2, latitude2]
},
"relation": "intersects"
}
}
}
]
}
}
一次只查询一个点。
如何一次搜索两个点?
如果您需要 OR 行为,则无需使用 bool/should
:
"query": {
"bool": {
"should": [{ <--- change this
"geo_shape": {
"border": {
"shape": {
"type": "point",
"coordinates": [longitude1, latitude1]
},
"relation": "intersects"
}
}
}, {
"geo_shape": {
"border": {
"shape": {
"type": "point",
"coordinates": [longitude2, latitude2]
},
"relation": "intersects"
}
}
}
]
}
}
我正在尝试在同一个查询中搜索两个点,如下所示。 但结果返回空。
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": [{
"geo_shape": {
"border": {
"shape": {
"type": "point",
"coordinates": [longitude1, latitude1]
},
"relation": "intersects"
}
}
}, {
"geo_shape": {
"border": {
"shape": {
"type": "point",
"coordinates": [longitude2, latitude2]
},
"relation": "intersects"
}
}
}
]
}
}
一次只查询一个点。
如何一次搜索两个点?
如果您需要 OR 行为,则无需使用 bool/should
:
"query": {
"bool": {
"should": [{ <--- change this
"geo_shape": {
"border": {
"shape": {
"type": "point",
"coordinates": [longitude1, latitude1]
},
"relation": "intersects"
}
}
}, {
"geo_shape": {
"border": {
"shape": {
"type": "point",
"coordinates": [longitude2, latitude2]
},
"relation": "intersects"
}
}
}
]
}
}