Elastcisearch

I am using the last Java Client API for Elasticsearch 7.17.5.
I have a boolean query builder and I want to add conditions before checking if a must clause is already there or not. But the issue is that I can build the query builder only 1 time.
How can I check if a clause is already there without actually calling .build method ?

Or Is it possible to add clause to BoolQuery object that we get after calling build.

       BoolQuery.Builder b = QueryBuilders.bool();
		
		b.filter(QueryBuilders.matchAll().build()._toQuery());
		
		if(b.build().must().isEmpty())
			b.must(QueryBuilders.matchAll().build()._toQuery());
		
		System.out.println(b.build());

This gives [UnsupportedOperationException]

		b.build().must().add(QueryBuilders.matchAll().build()._toQuery())

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.