我有以下两个查询:
GET places/_search
{
"query": {
"filtered": {
"filter": {
"bool": {
"should": [
{
"term": {
"approved": false
}
}
]
}
}
}
}
}
GET places/_search
{
"query": {
"filtered": {
"filter": {
"geo_bounding_box": {
"loc": {
"top_left": "54.6152065515344, -6.09334913041994",
"bottom_right": "54.5754258987271, -5.76633420732423"
}
}
}
}
}
}
两者都工作正常,但是我在合并查询时遇到问题,并且想知道是否有人可以提供帮助。基本上,我想检索指定边界框内所有项目,其中“approved”属性为false。
最佳答案
您可以保留filtered
查询并像这样在bool/must
过滤器中合并两个条件
curl -XPOST localhost:9200/places/_search -d '{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"approved": false
}
},
{
"geo_bounding_box": {
"loc": {
"top_left": "54.6152065515344, -6.09334913041994",
"bottom_right": "54.5754258987271, -5.76633420732423"
}
}
}
]
}
}
}
}
}'
关于elasticsearch - 组合 Elasticsearch 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31897546/