diff --git a/src/main/java/org/elasticsearch/index/query/BoolFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/BoolFilterBuilder.java index e24371ea04c..662d7be901a 100644 --- a/src/main/java/org/elasticsearch/index/query/BoolFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/BoolFilterBuilder.java @@ -55,6 +55,36 @@ public class BoolFilterBuilder extends BaseFilterBuilder { return this; } + /** + * Adds multiple should filters. + */ + public BoolFilterBuilder should(FilterBuilder... filterBuilders) { + for (FilterBuilder filterBuilder : filterBuilders) { + clauses.add(new Clause(filterBuilder, BooleanClause.Occur.SHOULD)); + } + return this; + } + + /** + * Adds multiple must filters. + */ + public BoolFilterBuilder must(FilterBuilder... filterBuilders) { + for (FilterBuilder filterBuilder : filterBuilders) { + clauses.add(new Clause(filterBuilder, BooleanClause.Occur.MUST)); + } + return this; + } + + /** + * Adds multiple must not filters. + */ + public BoolFilterBuilder mustNot(FilterBuilder... filterBuilders) { + for (FilterBuilder filterBuilder : filterBuilders) { + clauses.add(new Clause(filterBuilder, BooleanClause.Occur.MUST_NOT)); + } + return this; + } + /** * Adds a filter that should appear in the matching documents. For a boolean filter * with no MUST clauses one or more SHOULD clauses must match a document