如何为这种匹配构建查询?
(name="Adam" OR name="Bob) OR (age=21 && email="email@gmail.com")
如何将括号中的表达式与 OR 操作
“合并”BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("name","Adam"))
.should(QueryBuilders.matchQuery("name","Bob"));
BoolQueryBuilder queryBuilder2 = QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("age","21"))
.must(QueryBuilders.matchQuery("email","email@gmail.com"));
答案 0 :(得分:1)
您可以使用
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery().should(queryBuilder1).should(queryBuilder2)
这将作为两个QueryBuilders