class ElasticsearchHelper {

    public BoolQueryBuilder addIndexSearchFilterBooleanClause(List<IndexSearchFilter> indexSearchFilters, String bdefActiveIndex, String tagActiveIndex)
    {
        BoolQueryBuilder compoundBoolQueryBuilder = new BoolQueryBuilder();
        for (IndexSearchFilter indexSearchFilter : indexSearchFilters)
        {
            BoolQueryBuilder indexSearchFilterClauseBuilder = applySearchFilterClause(indexSearchFilter, bdefActiveIndex, tagActiveIndex);

            // If the search filter is marked with the exclusion flag then apply the entire compound filter clause on the request builder within a MUST NOT
            // clause.
            if (BooleanUtils.isTrue(indexSearchFilter.isIsExclusionSearchFilter()))
            {
                compoundBoolQueryBuilder.mustNot(indexSearchFilterClauseBuilder);
            }
            else
            {
                // Individual search filters are AND-ed (the compound filter clause is applied on the search request builder within a MUST clause)
                compoundBoolQueryBuilder.must(indexSearchFilterClauseBuilder);
            }
        }

        return compoundBoolQueryBuilder;
    }

}