Migrating ES 1.7 to 2.1 - boolQuery


(Andy) #1

Hi,

My experience with Elasticsearch is limited and I am trying to migrate some code from using ES 1.7 to ES 2.1.

In ES 1.7, the FilterBuilders.boolFilter().must() can accept an array of FilterBuilder and return a single one but the QueryBuilders.boolQuery().must() in ES 2.1 would only accept a single QueryBuilder.

What should I do in this situation?

Thank you.

Andy


(Jörg Prante) #2

Just do

BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
for (QueryBuilder queryBuilder : queryBuilders) {
    boolQuery.must(queryBuilder);
}

(Andy) #3

Thank you so much. Appreciate your prompt response.


(system) #4