本文整理了Java中org.elasticsearch.client.RestClientBuilder.setPathPrefix
方法的一些代码示例,展示了RestClientBuilder.setPathPrefix
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RestClientBuilder.setPathPrefix
方法的具体详情如下:
包路径:org.elasticsearch.client.RestClientBuilder
类名称:RestClientBuilder
方法名:setPathPrefix
[英]Sets the path's prefix for every request used by the http client.
For example, if this is set to "/my/path", then any client request will become "/my/path/" + endpoint
.
In essence, every request's endpoint is prefixed by this pathPrefix. The path prefix is useful for when Elasticsearch is behind a proxy that provides a base path or a proxy that requires all paths to start with '/'; it is not intended for other purposes and it should not be supplied in other scenarios.
[中]为http客户端使用的每个请求设置路径前缀。
例如,如果设置为“/my/path”,则任何客户端请求都将变成"/my/path/" + endpoint
。
本质上,每个请求的端点都以这个路径前缀为前缀。当Elasticsearch位于提供基本路径的代理或要求所有路径以“/”开头的代理之后时,路径前缀非常有用;它不用于其他目的,也不应在其他情况下提供。
代码示例来源:origin: apache/flink
@Override
public void configureRestClientBuilder(RestClientBuilder restClientBuilder) {
if (maxRetryTimeout != null) {
restClientBuilder.setMaxRetryTimeoutMillis(maxRetryTimeout);
}
if (pathPrefix != null) {
restClientBuilder.setPathPrefix(pathPrefix);
}
}
代码示例来源:origin: apache/storm
/**
* Creates a new {@link RestClient} using given {@link EsConfig}.
*
* @return {@link RestClient} for Elasticsearch connection
*/
public RestClient construct() {
RestClientBuilder builder = RestClient.builder(esConfig.getHttpHosts());
if (esConfig.getMaxRetryTimeoutMillis() != null) {
builder.setMaxRetryTimeoutMillis(esConfig.getMaxRetryTimeoutMillis());
}
if (esConfig.getDefaultHeaders() != null) {
builder.setDefaultHeaders(esConfig.getDefaultHeaders());
}
if (esConfig.getFailureListener() != null) {
builder.setFailureListener(esConfig.getFailureListener());
}
if (esConfig.getHttpClientConfigCallback() != null) {
builder.setHttpClientConfigCallback(esConfig.getHttpClientConfigCallback());
}
if (esConfig.getRequestConfigCallback() != null) {
builder.setRequestConfigCallback(esConfig.getRequestConfigCallback());
}
if (esConfig.getPathPrefix() != null) {
builder.setPathPrefix(esConfig.getPathPrefix());
}
return builder.build();
}
}
代码示例来源:origin: org.elasticsearch.plugin/reindex-client
});
if (Strings.hasLength(remoteInfo.getPathPrefix()) && "/".equals(remoteInfo.getPathPrefix()) == false) {
builder.setPathPrefix(remoteInfo.getPathPrefix());
代码示例来源:origin: hibernate/hibernate-search
private RestClient createClient(Properties properties, int maxRetryTimeoutMillis) {
String serverUrisString = ConfigurationParseHelper.getString(
properties,
ElasticsearchEnvironment.SERVER_URI,
ElasticsearchEnvironment.Defaults.SERVER_URI
);
ServerUris hosts = ServerUris.fromString( serverUrisString );
String pathPrefix = ConfigurationParseHelper.getString( properties, ElasticsearchEnvironment.PATH_PREFIX, null );
RestClientBuilder restClientBuilder = RestClient.builder( hosts.asHostsArray() )
/*
* Note: this timeout is currently only used on retries,
* but should we start using the synchronous methods of RestClient,
* it would be applied to synchronous requests too.
* See https://github.com/elastic/elasticsearch/issues/21789#issuecomment-287399115
*/
.setMaxRetryTimeoutMillis( maxRetryTimeoutMillis )
.setRequestConfigCallback( (b) -> customizeRequestConfig( properties, b ) )
.setHttpClientConfigCallback( (b) -> customizeHttpClientConfig( properties, hosts, b ) );
if ( !StringHelper.isEmpty( pathPrefix ) && !"/".equals( pathPrefix ) ) {
restClientBuilder.setPathPrefix( pathPrefix );
}
return restClientBuilder.build();
}
代码示例来源:origin: org.hibernate/hibernate-search-elasticsearch
private RestClient createClient(Properties properties, int maxRetryTimeoutMillis) {
String serverUrisString = ConfigurationParseHelper.getString(
properties,
ElasticsearchEnvironment.SERVER_URI,
ElasticsearchEnvironment.Defaults.SERVER_URI
);
ServerUris hosts = ServerUris.fromString( serverUrisString );
String pathPrefix = ConfigurationParseHelper.getString( properties, ElasticsearchEnvironment.PATH_PREFIX, null );
RestClientBuilder restClientBuilder = RestClient.builder( hosts.asHostsArray() )
/*
* Note: this timeout is currently only used on retries,
* but should we start using the synchronous methods of RestClient,
* it would be applied to synchronous requests too.
* See https://github.com/elastic/elasticsearch/issues/21789#issuecomment-287399115
*/
.setMaxRetryTimeoutMillis( maxRetryTimeoutMillis )
.setRequestConfigCallback( (b) -> customizeRequestConfig( properties, b ) )
.setHttpClientConfigCallback( (b) -> customizeHttpClientConfig( properties, hosts, b ) );
if ( !StringHelper.isEmpty( pathPrefix ) && !"/".equals( pathPrefix ) ) {
restClientBuilder.setPathPrefix( pathPrefix );
}
return restClientBuilder.build();
}
内容来源于网络,如有侵权,请联系作者删除!