committed by
Brian Clozel
parent
b34a311d02
commit
c789592e26
@@ -4146,9 +4146,6 @@ Spring Boot supports several clients:
|
||||
|
||||
Spring Boot provides a dedicated "`Starter`", `spring-boot-starter-data-elasticsearch`.
|
||||
|
||||
The https://github.com/searchbox-io/Jest[Jest] client has been deprecated, since both Elasticsearch and Spring Data Elasticsearch provide official support for REST clients.
|
||||
|
||||
|
||||
|
||||
[[boot-features-connecting-to-elasticsearch-rest]]
|
||||
==== Connecting to Elasticsearch using REST clients
|
||||
@@ -4192,33 +4189,6 @@ You can further tune how it is configured, as shown in the following example:
|
||||
If the configuration properties are not enough and you'd like to fully control the client
|
||||
configuration, you can register a custom `ClientConfiguration` bean.
|
||||
|
||||
[[boot-features-connecting-to-elasticsearch-jest]]
|
||||
==== Connecting to Elasticsearch using Jest
|
||||
Now that Spring Boot supports the official `RestHighLevelClient`, Jest support is deprecated.
|
||||
|
||||
If you have `Jest` on the classpath, you can inject an auto-configured `JestClient` that by default targets `http://localhost:9200`.
|
||||
You can further tune how the client is configured, as shown in the following example:
|
||||
|
||||
[source,properties,indent=0,configprops]
|
||||
----
|
||||
spring.elasticsearch.jest.uris=https://search.example.com:9200
|
||||
spring.elasticsearch.jest.read-timeout=10000
|
||||
spring.elasticsearch.jest.username=user
|
||||
spring.elasticsearch.jest.password=secret
|
||||
----
|
||||
|
||||
You can also register an arbitrary number of beans that implement `HttpClientConfigBuilderCustomizer` for more advanced customizations.
|
||||
The following example tunes additional HTTP settings:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{code-examples}/elasticsearch/jest/JestClientCustomizationExample.java[tag=customizer]
|
||||
----
|
||||
|
||||
To take full control over the registration, define a `JestClient` bean.
|
||||
|
||||
|
||||
|
||||
[[boot-features-connecting-to-elasticsearch-spring-data]]
|
||||
==== Connecting to Elasticsearch by Using Spring Data
|
||||
To connect to Elasticsearch, a `RestHighLevelClient` bean must be defined,
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.elasticsearch.jest;
|
||||
|
||||
import io.searchbox.client.config.HttpClientConfig;
|
||||
|
||||
import org.springframework.boot.autoconfigure.elasticsearch.jest.HttpClientConfigBuilderCustomizer;
|
||||
|
||||
/**
|
||||
* Example configuration for using a {@link HttpClientConfigBuilderCustomizer} to
|
||||
* configure additional HTTP settings.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class JestClientCustomizationExample {
|
||||
|
||||
/**
|
||||
* A {@link HttpClientConfigBuilderCustomizer} that applies additional HTTP settings
|
||||
* to the auto-configured jest client.
|
||||
*/
|
||||
// tag::customizer[]
|
||||
static class HttpSettingsCustomizer implements HttpClientConfigBuilderCustomizer {
|
||||
|
||||
@Override
|
||||
public void customize(HttpClientConfig.Builder builder) {
|
||||
builder.maxTotalConnection(100).defaultMaxTotalConnectionPerRoute(5);
|
||||
}
|
||||
|
||||
}
|
||||
// end::customizer[]
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user