2015-04-03 70 views
2

我有一個索引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

如何結合幾個字段和值進行搜索?

回答

2

由於@rvheddeg上述建議,這裏是爲我的作品查詢:

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