# Default IndicesOptions in SearchRequest and disable specific deprecation warnings

**URL:** <https://discuss.elastic.co/t/default-indicesoptions-in-searchrequest-and-disable-specific-deprecation-warnings/299242>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [March 9, 2022, 4:20pm UTC](https://discuss.elastic.co/t/default-indicesoptions-in-searchrequest-and-disable-specific-deprecation-warnings/299242 "2022-03-09T16:20:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joschi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joschi/32/44946_2.png) [@joschi](https://discuss.elastic.co/u/joschi)\
**Post date:** [March 9, 2022, 4:20pm UTC](https://discuss.elastic.co/t/default-indicesoptions-in-searchrequest-and-disable-specific-deprecation-warnings/299242/1 "2022-03-09T16:20:40Z")

</div>

Hi folks,

this is a follow-up to the automatically closed topic at [Disable specific deprecation warnings](https://discuss.elastic.co/t/disable-specific-deprecation-warnings/292678).

We've updated to Elasticsearch 7.16.3 on the servers and for our clients now but still get this deprecation message without explicitly setting the `ignore_throttled` parameter in our search requests.

It turns out that the default `IndicesOptions` for `SearchRequest` include this by default:

> <https://github.com/elastic/elasticsearch/blob/v7.16.3/server%2Fsrc%2Fmain%2Fjava%2Forg%2Felasticsearch%2Faction%2Fsearch%2FSearchRequest.java#L102>

> <https://github.com/elastic/elasticsearch/blob/v7.16.3/server%2Fsrc%2Fmain%2Fjava%2Forg%2Felasticsearch%2Faction%2Fsupport%2FIndicesOptions.java#L155-L158>

> <https://github.com/elastic/elasticsearch/blob/v7.16.3/server%2Fsrc%2Fmain%2Fjava%2Forg%2Felasticsearch%2Faction%2Fsupport%2FIndicesOptions.java#L397-L399>

Additionally, it's added to pretty much all requests anyway via the `RequestConverters` class:

> <https://github.com/elastic/elasticsearch/blob/v7.16.3/client%2Frest-high-level%2Fsrc%2Fmain%2Fjava%2Forg%2Felasticsearch%2Fclient%2FRequestConverters.java#L1089>

How do other people handle this? Are you just ignoring the deprecation warnings in the logs on your Elasticsearch nodes? For us this is very annoying because we have _a lot_ of requests going on and have gigabytes of just the deprecation message in our logs because of these defaults.

Or maybe are we "holding it wrong"? Should we use the Java client differently? If so, how would we "hold" it correctly?

> [@Disable specific deprecation warnings](https://discuss.elastic.co/t/disable-specific-deprecation-warnings/292678/8):
>
> Repeating for emphasis: If your application needs to support older versions of Elasticsearch then this approach will need some kind of mechanism that detects the cluster version and adjusts your application behaviour accordingly. It's not just the deprecation warning, it's also the fact that you're using a feature which is deprecated. IMO the latter bit is worth addressing, and once addressed it'll get rid of the warning too.

So we aren't using the deprecated feature. It's added automatically for all of our requests with the (almost) latest version of Elasticsearch 7.16.3 and its corresponding Java client. How can we disable it?

Best regards,  
Jochen

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [March 9, 2022, 5:02pm UTC](https://discuss.elastic.co/t/default-indicesoptions-in-searchrequest-and-disable-specific-deprecation-warnings/299242/2 "2022-03-09T17:02:29Z")

</div>

> [@joschi](#):
>
> the (almost) latest version of Elasticsearch 7.16.3 and its corresponding Java client

You're using the deprecated [high-level REST client](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high.html), rather than the [Java API client](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/7.17/index.html). It's unfortunate that there are so many Java clients in 7.x, there were good reasons for this but that doesn't make it any less confusing. I believe the new client should avoid deprecation warnings.

---

<div class="post-metadata">

**Author:** ![joschi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joschi/32/44946_2.png) [@joschi](https://discuss.elastic.co/u/joschi)\
**Post date:** [March 10, 2022, 7:52am UTC](https://discuss.elastic.co/t/default-indicesoptions-in-searchrequest-and-disable-specific-deprecation-warnings/299242/3 "2022-03-10T07:52:47Z")

</div>

@DavidTurner Yes, we're using the Java High Level REST Client in version 7.16.3.

I would _not_ have expected that it's causing the deprecation warning without any possibility whatsoever to disable it, either by not sending the deprecated parameter or by disabling the warning message.

So out of the box you cannot use Elasticsearch 7.16.x or later with the Java High Level REST Client _without_ producing the deprecation warning, which makes up ~95% of log messages in our ES clusters. 🤯

This forces us to do a big bang migration to the new [Java client](https://github.com/elastic/elasticsearch-java) (which has hopefully matured enough by now) without giving the option to do a gradual migration, which we planned originally.  
I found that a bit surprising for a "minor version" upgrade (7.15 -\> 7.16). ☹

For reference, here's a pull request of a colleague of mine to avoid the deprecation warning without breaking backward compatibility in ES 7.x:

> <https://github.com/elastic/elasticsearch/pull/84827>
>
> \# Why
> 
> When setting indices options in the (now deprecated) \`RestHighLevelClie…nt\`, even if we do not explicitly set \`ignore\_throttled\`, the client sends the \`ignore\_throttled\` parameter to the server. Since 7.16, this parameter is deprecated, and so the server sends back a warning header which is unconditionally logged.
> 
> This is extremely spammy in our environments because we usually set non-deprecated indices options, and so all of our requests are sending (without our control) the \`ignore\_throttled\` parameter.
> 
> The \`RestHighLevelClient\` should not send the deprecated \`ignore\_throttled\` parameter unless it is set to the non default value of \`false\`.
> 
> \# What
> 
> This PR changes the \`RequestConverters\` to only send the \`ignore\_throttled\` parameter when it is set to a non-default value. Otherwise it does not include it.
> 
> \# Other notes
> 
> Happy to submit this against \`master\` however this should most definitely be available in the version where the deprecation was introduced (7.16) so I targeted that branch.

Maybe you could consider merging it for Elasticsearch 7.16.4 and onwards.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [March 10, 2022, 8:12am UTC](https://discuss.elastic.co/t/default-indicesoptions-in-searchrequest-and-disable-specific-deprecation-warnings/299242/4 "2022-03-10T08:12:17Z")

</div>

I've raised this with some of my colleagues who are taking a closer look. The 7.16 branch became [unmaintained](https://www.elastic.co/support/eol) since the release of 7.17.0 so there won't be a 7.16.4, but it's possible this can be addressed in a later 7.17.x release.

---

<div class="post-metadata">

**Author:** ![joschi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joschi/32/44946_2.png) [@joschi](https://discuss.elastic.co/u/joschi)\
**Post date:** [March 10, 2022, 8:23am UTC](https://discuss.elastic.co/t/default-indicesoptions-in-searchrequest-and-disable-specific-deprecation-warnings/299242/5 "2022-03-10T08:23:45Z")

</div>

Thanks a lot, David! ❤

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 7, 2022, 8:24am UTC](https://discuss.elastic.co/t/default-indicesoptions-in-searchrequest-and-disable-specific-deprecation-warnings/299242/6 "2022-04-07T08:24:11Z")

</div>

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