Question:
I am migrating from ElasticSearch v1.0.0 to v7.13.1. I know that support for Type specification has been removed by ElasticSearch version beyond 7.0.0. Also, there are certain improvements done by the ElasticSearch in terms of classes such as TermsAggregationBuilder replaces TermsBuilder.But when I am preparing queries using QueryBuilders and AggregationBuilder, I could see some extra fields generated, that I don’t want.
Is there any way to avoid them programmatically?
Before
Query comparison with old and new elasticsearch version
Before
Answer:
What you see as a extra fields are actually the params of the query for examplematch
query in your 7.X looks like below:operator
, prefix_length
, lenient
all are the params of match
query and even if you don’t provide it will be added with their default values, these will be added at Elasticsearch side when you hit the query in JSON format without these params, so don’t worry about them, if you want you can change some of these params value to see the corresponding impact on your query results, like change operator
to AND
and number of search results for multi-terms will be less.Note: You can also check the code of MatchQueryBuilder in the Elasticsearch code base to understand they are using the builder design pattern, and how they are passing the default values of the params.
Hope this helps.
If you have better answer, please add a comment about this, thank you!