As seen in #22358, applications should define RestClientBuilderCustomizer beans to change the client configuration, not define a RestClient because this won't be used to create the RestHighLevelClient for the application.

Our docs should read:

You can also register an arbitrary number of beans that implement RestClientBuilderCustomizer for more advanced customizations. To take full control over the registration, define a RestClientBuilder bean.

If you have the org.elasticsearch.client:elasticsearch-rest-high-level-client dependency on the classpath, Spring Boot will auto-configure a RestHighLevelClient, which leverages any existing RestClientBuilder bean, reusing its HTTP configuration.