常用的查询方式类比mysql
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.6.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.6.1</version>
</dependency>
select * from user where about='中华人民共和国' and firstName=‘张’
QueryBuilders.boolQuery().must(QueryBuilders.termQuery("about","中华人民共和国")).must(QueryBuilders.termQuery("firstName","张"))
select * from user where about='中华人民共和国' and firstName=‘王’
QueryBuilders.boolQuery().should(QueryBuilders.termQuery("about","中华人民共和国")).should(QueryBuilders.termQuery("firstName","王"))
select * from user where firstName='张' and( firstName='王’ or about='中华人民共和国公民')
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("firstName","张"))
.must(QueryBuilders.boolQuery()
.should(QueryBuilders.termQuery("firstName","王"))
.should(QueryBuilders.termQuery("about","中华人民共和国公民"))
select * from user where about like '%中华%'
QueryBuilders.wildcardQuery("about","*中华*")
select * from user where about in ('中华人民共和国','中华人民共和国公民')
QueryBuilders.boolQuery()
.should(QueryBuilders.termQuery("about","中华人民共和国"))
.should(QueryBuilders.termQuery("about","中华人民共和国公民"))