• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to disable auto-generation of default fields in ElasticSearch Query with TermsAggregationBuilder and QueryBuilders

Resolved: How to disable auto-generation of default fields in ElasticSearch Query with TermsAggregationBuilder and QueryBuilders

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

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
After
Also I am using matchQuery() to prepare match query with the upgraded ES version. Still I could see some extra fields. Same goes for Order as well.
Query comparison with old and new elasticsearch version
Before
Query developed with new ES version QueryBuilder

Answer:

What you see as a extra fields are actually the params of the query for example match query in your 7.X looks like below:
These 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!

elasticsearch java
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Using AWK to count multiple patterns in a file

01/04/2023

Resolved: significance letter above bar graphic in wrong order

01/04/2023

Resolved: VBA – Applying border around the areas with value/text

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.