我该如何暗示“应该”操作
(“tag” =“A” OR“tag” =“B”)和“name” =“cat”
喜欢 ?
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("tag","A"))
.shold(QueryBuilders.matchQuery("tag","B"))
.must(QueryBuilders.matchQuery(“name”,“cat”)));
最佳答案
如果要执行("tag"="A" OR "tag"="B") and "name"="cat"
,则可以执行以下操作:
BoolQueryBuilder aOrB = QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("tag","A"))
.should(QueryBuilders.matchQuery("tag","B"))
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(aOrB);
.must(QueryBuilders.matchQuery("name","cat"));