iam trying to send a bool query against my elasticSearch, that filters out documents. How can i filter boolean expressions like (A AND B AND C) AND (D OR E OR F) AND G with BooleanQueryBuilder Api in Java? I tried with the filter method, but i get no results back. For example:
Imagine A, B, C, D, E, F, G are events where the attribute "name" must match "Robin" for example.
private QueryBuilder getQueryBuilder() {
BoolQueryBuilder boolQueryBuilder1 = QueryBuilders
.boolQuery()
.filter(QueryBuilders.matchQuery(D).operator(Operator.OR))
.filter(QueryBuilders.matchQuery(E).operator(Operator.OR))
.filter(F);
BoolQueryBuilder boolQueryBuilder2 = QueryBuilders
.boolQuery()
.filter(QueryBuilders.matchQuery(A).operator(Operator.AND))
.filter(QueryBuilders.matchQuery(B).operator(Operator.AND))
.filter(QueryBuilders.matchQuery(C));
BoolQueryBuilder boolQueryBuilder3 = QueryBuilders
.boolQuery()
.filter(G);
BoolQueryBuilder boolQueryBuilder = QueryBuilders
.boolQuery()
.filter(boolQueryBuilder1)
.filter(boolQueryBuilder2)
.filter(boolQueryBuilder3);
return boolQueryBuilder;
}
I know this example is not very good, but i hope u can help me! Thanks!