当前位置: 首页>数据库>正文

ElasticSearch 两个BoolQueryBuilder满足其中一个

BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();

BoolQueryBuilder boolQueryBuilder1 = QueryBuilders.boolQuery();
for (String word : wordList) {
    boolQueryBuilder1.must(QueryBuilders.termQuery(FIELD1, word));
}

BoolQueryBuilder boolQueryBuilder2 = QueryBuilders.boolQuery();
for (String word : wordList) {
    boolQueryBuilder2.must(QueryBuilders.termQuery(FIELD2, word));
}

boolQueryBuilder.should(boolQueryBuilder1).should(boolQueryBuilder2);



https://www.xamrdz.com/database/62d1963411.html

相关文章: