2015-08-08 75 views
0

我有以下2个查询:结合弹性搜索查询

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。

回答

1

你可以保持您的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" 
       } 
       } 
      } 
      ] 
     } 
     } 
    } 
    } 
}'