如何查找elasticsearch中与字段和值匹配的所有文档?

问题描述:

我有一个索引usersuser类型。映射是动态的。现在user HS一个结构如下:如何查找elasticsearch中与字段和值匹配的所有文档?

"user": { 
     "nested": { 
      "one":51 
     }, 
     "other": { 
      "two":"hi!" 
     }, 
     "three":false 
    } 

我需要找到具有other.two字段值hi或具有价值falsethree领域的所有用户。例如。具有other.two的用户必须具有hi值或three字段值为false。如何从弹性搜索中选择这个?

我曾尝试:

GET /users/user/_search 
{"query": {"match": {"other.two": "hi"}}} 

返回用户的我,但

GET /users/user/_search 
    {"query": {"match": {"other.two": "hi", "three":false}}} 

返回我SearchPhaseExecutionException

如何结合几个字段和值进行搜索?

由于@rvheddeg上述建议,这里是为我的作品查询:

{ 
"query": { 
    "bool": { 
     "should": [ 
       { "match": { "other.two": "hi" }}, 
       { "match": { "three": false }} 
      ], 
      "minimum_should_match": 1 
     } 
    } 
}