2015-01-26 252 views
0

我的指數看起來像這樣如何在ElasticSearch中進行whereIn查詢?

{name : 'John Doe',group_id : '1'}, 
{ name : 'Jane Doe', group_id : '2'} 
{ name : 'John Doe', group_id : '3'} 

,我想返回所有索引,其GROUP_ID是這個數組中[1,2]

因此將返回:

{name : 'John Doe',group_id : '1'}, 
{ name : 'Jane Doe', group_id : '2'} 

回答

0

你可以使用Terms Query。將<index>替換爲索引名稱,用<type>替換爲要搜索的類型。

POST <index>/<type>/_search 
{ 
    "query": { 
     "terms": { 
     "group_id": [ 
      "1", 
      "2" 
     ] 
     } 
    } 
}