错误的写法:
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder
.must(QueryBuilders.rangeQuery(field).gt(start))
.should(QueryBuilders.rangeQuery(field).gt(start))
.should(QueryBuilders.rangeQuery(field).gte(start).lte(end));
正确的写法:
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
QueryBuilder queryBuilder = QueryBuilders.boolQuery()
.should(QueryBuilders.rangeQuery(field).gt(start))
.should(QueryBuilders.rangeQuery(field).gte(start).lte(end));
boolQueryBuilder.must(queryBuilder);
参考:
https://blog.csdn.net/q18810146167/article/details/89404901