Type to search.

Elasticsearch Java Client 9.5.0

Discover what changed in the 9.5.0 version of the Java client.

This version presents many updates to existing fields that were wrongly mapped, or incomplete. Here is the complete list of changes:

From single value to union type

Some fields have been remapped to tagged unions to correctly represent that they can accept more than one shape.

  • elasticsearch._types.mapping.DocValuesPropertyBase

    • docValues: modified from Boolean to elasticsearch._types.mapping.DocValues, now a union of a simple Boolean (enabled) or a DocValuesConfig object (config)
  • elasticsearch.inference.RerankRequest

    • input: modified from List<String> to elasticsearch.inference.rerank.RerankInput, now a union of a list of strings (string) or a list of objects (object)
    • query: modified from String to elasticsearch.inference.rerank.RerankQuery, now a union of a simple string (string) or an object (object)
Snapshot source-only repository remapping

SourceOnlyRepositorySettings is now a tagged union discriminated by delegate_type: choosing a delegate type (azure, gcs, url, s3 or fs) makes its own settings available.

  • elasticsearch.snapshot.SourceOnlyRepositorySettings: now a tagged union (azure, gcs, url, s3, fs)

For example, to register a source-only repository delegating to a shared file system (fs):

Java
esClient.snapshot().createRepository(r -> r
    .name("my_src_only_repository")
    .repository(repo -> repo
        .source(source -> source
            .settings(settings -> settings
                .fs(fs -> fs
                    .location("my_backup_repository")
                )
            )
        )
    )
);
Watcher fixes

Most of the watcher types were outdated and wrongly mapped. The following changes bring them in line with the actual API:

  • elasticsearch.watcher.ExecutionResultCondition

    • status: modified from elasticsearch.watcher.ActionStatusOptions to elasticsearch.watcher.ExecutionResultStatus
  • elasticsearch.watcher.ExecutionResultInput

    • status: modified from elasticsearch.watcher.ActionStatusOptions to elasticsearch.watcher.ExecutionResultStatus
  • elasticsearch.watcher.IndexResult

    • response: modified from elasticsearch.watcher.IndexResultSummary to List<IndexResultSummary>. IndexResult is now a union that can hold either the response of an executed index action or the request that would have run when the action is simulated
  • elasticsearch.watcher.IndexResultSummary

    • created: modified from boolean to Boolean, now optional
    • version: modified from long to Long, now optional
  • elasticsearch.watcher.SearchInputRequestBody: removed

  • elasticsearch.watcher.SearchInputRequestDefinition

    • body: modified from elasticsearch.watcher.SearchInputRequestBody to elasticsearch.core.search.SearchRequestBody
Other changes
  • elasticsearch._types.analysis.SynonymTokenFilterBase

    • synonymsSet: modified from String to List<String>, now required
  • elasticsearch.cluster.stats.DenseVectorOffHeapStats

    • totalCenifSizeBytes: renamed to totalCenivfSizeBytes
    • totalCenifSize: renamed to totalCenivfSize
  • elasticsearch.indices.stats.ShardStats

    • indices: modified from elasticsearch.indices.stats.IndicesStats to Map<String, ShardStats>, now required
  • elasticsearch.inference.EmbeddingContentObject

    • content: modified from elasticsearch.inference.EmbeddingContentObjectContents to List<EmbeddingContentObjectItem>
  • elasticsearch.inference.EmbeddingContentObjectContents: removed

  • elasticsearch.security.Role

    • indices: modified from List<IndicesPrivileges> to List<IndicesPrivilegesRead>
  • elasticsearch._types.mapping.SourceField

    • compress: removed
    • compressThreshold: removed
Automatic request retry

Introduced with #954, adds new retry functionality to the client, configurable both for all requests:

Java
try (ElasticsearchClient client = ElasticsearchClient.of(e -> e
    .host(serverUrl)
    .apiKey(apikey)
    .retryConfig(r -> r
        .backoffPolicy(BackoffPolicy.constantBackoff(5000L,5))
        .retryableExceptions(Set.of(SocketException.class))
        .retryableStatuses(429,503)
    )
))
  1. defaults to BackoffPolicy.noBackoff()
  2. defaults to IOException.class
  3. defaults to 429, 500, 502, 503, 504

Or just for a single request:

Java
try (ElasticsearchClient client = ElasticsearchClient.of(e -> e
    .host(serverUrl)
    .apiKey(apikey)
)) {
    client.withTransportOptions(o -> o
        .retryConfig(r -> r
            .backoffPolicy(BackoffPolicy.constantBackoff(5000L,5))
        ))
    .ping();
}

The delegate client (Rest5Client, RestClient or any custom client) is wrapped in an instance of RetryingHttpClient, which takes care of the retrying logic according to the configuration. This only concerns the same node the request was originally sent to, it's still the underlying client's responsibility to handle dead node logic and node selection.

Nothing was deprecated in this version of the client.