1. SQL语句示例
select * from table where t_id in (1,2,3,4)
2. 对应es查询语法
GET /index/type/_search
{
"query": {
"terms": {
"t_id": [
1,2,3,4 ]
}
}
}
3. 对应Java API
SearchRequestBuilder searchRequestBuilder =
client.prepareSearch(index).setTypes(type).setSearchType(SearchType.QUERY_THEN_FETCH);
...
searchRequestBuilder.setQuery(QueryBuilders.termsQuery("t_id", idList));
4. java API pom配置
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.4.1</version>
</dependency>
5. 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)