ES 8 Java client: BoolQuery.Builder no longer has hasClauses() method

Hello.

We are upgrading our elastic java client from 6.8.10 to 8.1.3 and it seems BoolQuery.Builder doesn't have hasClauses() method anymore. Is there any workaround which provides the same functionality?

Thanks in advance.

The builders only have setters. A workaround (assuming you have a BoolQuery bq object) is bool hasClauses = !bq.must().isEmpty() && !bq.mustNot().isEmpty() && !bq.should().isEmpty()

1 Like

Thanks for your response, I was considering to go with the same approach.

In my opinion it'd have been great if we still had the built-in hasClauses() method not in the builder but in BoolQuery class :upside_down_face:

This is indeed a good suggestion!