I need to translate my filter / query syntax (Elasticsearch 1.4) to Elasticsearch 7.x syntax. For FilterBuilders.andFilter I found that I should use boolquery() with filter clause and it works. But what about FilterBuilders.orFilter?
FilterBuilders.boolFilter().must(nestedFilters) translated to QueryBuilders.boolQuery().must(nestedQueries)
FilterBuilders.andFilter(nestedFilters)) translated to QueryBuilders.boolQuery().filter(nestedQueries)
FilterBuilders.boolFilter().should(nestedFilters) translated to QueryBuilders.boolQuery().should(nestedQueries)
FilterBuilders.orFilter(nestedFilters) translated to ?
The trick is to have a bool query, that does not contain anything in the must, must_not and filter parts, but only in the should clause. In that case this is considered an or... like this
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.