2017-03-31 69 views
0

我想提出一些陣列上的請求,儘管重複相同期限的請求幾個時間使用不同的應容器替換多個項請求查找關鍵詞elasticsearch:通過一個唯一的請求

這是我的請求在三個不同的詞條查詢應該在容器中

POST /test_index/film_type/_search 
{ 
    "query": { 
    "bool": { 
     "filter": [ 
     { 
      "bool": { 
      "should": [ 
       { 
       "term": { 
        "id_film": { 
        "value": 4 
        } 
       } 
       }, 
       { 
       "term": { 
        "id_film": { 
        "value": 5 
        } 
       } 
       }, 
       { 
       "term": { 
        "id_film": { 
        "value": 45 
        } 
       } 
       } 
      ] 
      } 
     } 
     ] 
    } 
    } 
} 

你知道如何做到這一點嗎?

回答

3

你可以在Simple Query String Query

小例子看看:

POST test/test/1 
{ 
    "film-id": 1 
} 

POST test/test/2 
{ 
    "film-id": 2 
} 

POST test/test/3 
{ 
    "film-id": 3 
} 


GET test/_search 
{ 
    "query": { 
    "simple_query_string": { 
     "query": "1 | 2", 
     "fields": [ 
      "film-id" 
     ] 
    } 
    } 
} 

結果:

"hits": { 
    "total": 2, 
    "max_score": 1, 
    "hits": [ 
     { 
     "_index": "test", 
     "_type": "test", 
     "_id": "2", 
     "_score": 1, 
     "_source": { 
      "film-id": 2 
     } 
     }, 
     { 
     "_index": "test", 
     "_type": "test", 
     "_id": "1", 
     "_score": 1, 
     "_source": { 
      "film-id": 1 
     } 
     } 
    ] 
    } 
} 

希望這有助於!