I need one example where using elastic 8 dsl creates query which includes boolquery with should shouldnot must
.query(q -> q.bool(
b -> b.must(ListObj).should(listShould).mustNot(listMustNot))));
I need one example where using elastic 8 dsl creates query which includes boolquery with should shouldnot must
.query(q -> q.bool(
b -> b.must(ListObj).should(listShould).mustNot(listMustNot))));
This is a suggestion:
var boolQuery = BoolQuery.of(bq -> bq
.should(List.of(MatchQuery.of(mq -> mq.query("value").field("field"))._toQuery()))
.must(List.of(MatchQuery.of(mq -> mq.query("value").field("field"))._toQuery()))
.mustNot(List.of(MatchQuery.of(mq -> mq.query("value").field("field"))._toQuery()))
);
var request = SearchRequest.of(s -> s.query(boolQuery._toQuery()));
very nice and thanks for this.
I doubt why elastic doc does not cover this
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.