Hi, Iam migrating from RestHighLevelClient to ElasticsearchClient and as part of this change i need to replace NativeSearchQuery and NativeSearchQueryBuilder with NativeQuery and NativeQueryBuilder
But iam not able to pass the boolQueryBuilder to the existing withQuery API ,
Can you please advise the right solution for this
Below is the pseudocode
Before Migrating:
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(new TermsQueryBuilder(fieldName+".keyword", flVal));
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder();
searchQueryBuilder.withQuery(boolQueryBuilder);
NativeSearchQuery queryn = searchQueryBuilder.build();
elasticsearchTemplate = new ElasticsearchTemplate(elasticsearchClient);
hits = elasticsearchTemplate.search(queryn, getMappedEntityClass(), IndexCoordinates.of(getIndexName()));
After Migrating:
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(new TermsQueryBuilder(fieldName+".keyword", flVal));
NativeQueryBuilder searchQueryBuilder = new NativeQueryBuilder();
searchQueryBuilder.withQuery(boolQueryBuilder); //
The above last line throws compilation exception,
Can you please suggest the alternative for this so that the above current working logic works with NativeQueryBuilder and NativeQuery
Thanks,