2017-03-31 46 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 
     } 
     } 
    ] 
    } 
} 

希望这有助于!