elasticsearch in 语句

SQL语句示例

select * from table where t_id in (1,2,3,4)
对应es查询语句

GET /index/type/_search
{
  "query": {
    "terms": {
      "t_id": [
        1,2,3,4      ]
    }
  }
}

对应Java API 

SearchRequestBuilder searchRequestBuilder =
                client.prepareSearch(index).setTypes(type).setSearchType(SearchType.QUERY_THEN_FETCH);
...
searchRequestBuilder.setQuery(QueryBuilders.termsQuery("t_id", idList));// in语句

java API pom配置

			
				org.elasticsearch.client
				transport
				5.4.1
			
			
				org.elasticsearch
				elasticsearch
				5.4.1
			

jdk信息

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)




你可能感兴趣的:(elasticsearch)