diff --git a/build.gradle.kts b/build.gradle.kts index ef6fbc7e5..bc25c8637 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -44,17 +44,12 @@ subprojects { allprojects { group = "co.elastic.clients" // Release manager provides a $VERSION. If not present, it's a local or CI snapshot build. - // also need to add the qualifier in case it's a staging build version = "" if (System.getenv("VERSION")==null) { version = (File(project.rootDir, "config/version.txt").readText().trim() + "-SNAPSHOT") } - else if (System.getenv("VERSION").contains("-")) { - // Either SNAPSHOT or a version qualifier included in $VERSION for ad-hoc releases - version = System.getenv("VERSION") - } else { - version = System.getenv("VERSION") + "-" + File(project.rootDir, "config/version-qualifier.txt").readText().trim() + version = System.getenv("VERSION") } repositories { diff --git a/config/version-qualifier.txt b/config/version-qualifier.txt deleted file mode 100644 index 0da56cbcc..000000000 --- a/config/version-qualifier.txt +++ /dev/null @@ -1 +0,0 @@ -alpha1 diff --git a/config/version.txt b/config/version.txt index 47da986f8..44931da26 100644 --- a/config/version.txt +++ b/config/version.txt @@ -1 +1 @@ -9.1.0 +9.1.1 diff --git a/java-client/src/main-flavored/java/co/elastic/clients/transport/VersionInfo.java b/java-client/src/main-flavored/java/co/elastic/clients/transport/VersionInfo.java index 43105b579..b1995fd1d 100644 --- a/java-client/src/main-flavored/java/co/elastic/clients/transport/VersionInfo.java +++ b/java-client/src/main-flavored/java/co/elastic/clients/transport/VersionInfo.java @@ -21,5 +21,5 @@ // Package private class VersionInfo { - static final String VERSION = "9.1.0"; + static final String VERSION = "9.1.1"; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/DateHistogramAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/DateHistogramAggregation.java index 5a3ad063b..17b3cd7ad 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/DateHistogramAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/DateHistogramAggregation.java @@ -656,6 +656,7 @@ public final Builder order(List> list) { *

* Adds one or more values to order. */ + @SafeVarargs public final Builder order(NamedValue value, NamedValue... values) { this.order = _listAdd(this.order, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/HistogramAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/HistogramAggregation.java index 9fefe77b0..31775e72e 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/HistogramAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/HistogramAggregation.java @@ -500,6 +500,7 @@ public final Builder order(List> list) { *

* Adds one or more values to order. */ + @SafeVarargs public final Builder order(NamedValue value, NamedValue... values) { this.order = _listAdd(this.order, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/MultiTermsAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/MultiTermsAggregation.java index 78409eeb5..5d0a75a67 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/MultiTermsAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/MultiTermsAggregation.java @@ -329,6 +329,7 @@ public final Builder order(List> list) { *

* Adds one or more values to order. */ + @SafeVarargs public final Builder order(NamedValue value, NamedValue... values) { this.order = _listAdd(this.order, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsAggregation.java index ff8002baf..2d3b47d8d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsAggregation.java @@ -713,6 +713,7 @@ public final Builder order(List> list) { *

* Adds one or more values to order. */ + @SafeVarargs public final Builder order(NamedValue value, NamedValue... values) { this.order = _listAdd(this.order, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/ChunkingSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/ChunkingSettings.java index 414cdd641..98d95c40b 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/ChunkingSettings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/ChunkingSettings.java @@ -32,6 +32,7 @@ import jakarta.json.stream.JsonGenerator; import java.lang.Integer; import java.lang.String; +import java.util.List; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -63,6 +64,10 @@ public class ChunkingSettings implements JsonpSerializable { private final String strategy; + private final String separatorGroup; + + private final List separators; + private final int maxChunkSize; @Nullable @@ -76,6 +81,8 @@ public class ChunkingSettings implements JsonpSerializable { private ChunkingSettings(Builder builder) { this.strategy = ApiTypeHelper.requireNonNull(builder.strategy, this, "strategy"); + this.separatorGroup = ApiTypeHelper.requireNonNull(builder.separatorGroup, this, "separatorGroup"); + this.separators = ApiTypeHelper.unmodifiableRequired(builder.separators, this, "separators"); this.maxChunkSize = ApiTypeHelper.requireNonNull(builder.maxChunkSize, this, "maxChunkSize", 0); this.overlap = builder.overlap; this.sentenceOverlap = builder.sentenceOverlap; @@ -87,7 +94,18 @@ public static ChunkingSettings of(Functionsentence or word. + * Required - The chunking strategy: sentence, word, + * none or recursive. + *

+ * + *

+ * Learn more about different chunking strategies in the linked documentation. *

* API name: {@code strategy} */ @@ -95,6 +113,41 @@ public final String strategy() { return this.strategy; } + /** + * Required - This parameter is only applicable when using the + * recursive chunking strategy. + *

+ * Sets a predefined list of separators in the saved chunking settings based on + * the selected text type. Values can be markdown or + * plaintext. + *

+ * Using this parameter is an alternative to manually specifying a custom + * separators list. + *

+ * API name: {@code separator_group} + */ + public final String separatorGroup() { + return this.separatorGroup; + } + + /** + * Required - A list of strings used as possible split points when chunking text + * with the recursive strategy. + *

+ * Each string can be a plain string or a regular expression (regex) pattern. + * The system tries each separator in order to split the text, starting from the + * first item in the list. + *

+ * After splitting, it attempts to recombine smaller pieces into larger chunks + * that stay within the max_chunk_size limit, to reduce the total + * number of chunks generated. + *

+ * API name: {@code separators} + */ + public final List separators() { + return this.separators; + } + /** * Required - The maximum size of a chunk in words. This value cannot be higher * than 300 or lower than 20 (for @@ -145,6 +198,19 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("strategy"); generator.write(this.strategy); + generator.writeKey("separator_group"); + generator.write(this.separatorGroup); + + if (ApiTypeHelper.isDefined(this.separators)) { + generator.writeKey("separators"); + generator.writeStartArray(); + for (String item0 : this.separators) { + generator.write(item0); + + } + generator.writeEnd(); + + } generator.writeKey("max_chunk_size"); generator.write(this.maxChunkSize); @@ -175,6 +241,10 @@ public String toString() { public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { private String strategy; + private String separatorGroup; + + private List separators; + private Integer maxChunkSize; @Nullable @@ -184,7 +254,18 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Integer sentenceOverlap; /** - * Required - The chunking strategy: sentence or word. + * Required - The chunking strategy: sentence, word, + * none or recursive. + *

+ * + *

+ * Learn more about different chunking strategies in the linked documentation. *

* API name: {@code strategy} */ @@ -193,6 +274,66 @@ public final Builder strategy(String value) { return this; } + /** + * Required - This parameter is only applicable when using the + * recursive chunking strategy. + *

+ * Sets a predefined list of separators in the saved chunking settings based on + * the selected text type. Values can be markdown or + * plaintext. + *

+ * Using this parameter is an alternative to manually specifying a custom + * separators list. + *

+ * API name: {@code separator_group} + */ + public final Builder separatorGroup(String value) { + this.separatorGroup = value; + return this; + } + + /** + * Required - A list of strings used as possible split points when chunking text + * with the recursive strategy. + *

+ * Each string can be a plain string or a regular expression (regex) pattern. + * The system tries each separator in order to split the text, starting from the + * first item in the list. + *

+ * After splitting, it attempts to recombine smaller pieces into larger chunks + * that stay within the max_chunk_size limit, to reduce the total + * number of chunks generated. + *

+ * API name: {@code separators} + *

+ * Adds all elements of list to separators. + */ + public final Builder separators(List list) { + this.separators = _listAddAll(this.separators, list); + return this; + } + + /** + * Required - A list of strings used as possible split points when chunking text + * with the recursive strategy. + *

+ * Each string can be a plain string or a regular expression (regex) pattern. + * The system tries each separator in order to split the text, starting from the + * first item in the list. + *

+ * After splitting, it attempts to recombine smaller pieces into larger chunks + * that stay within the max_chunk_size limit, to reduce the total + * number of chunks generated. + *

+ * API name: {@code separators} + *

+ * Adds one or more values to separators. + */ + public final Builder separators(String value, String... values) { + this.separators = _listAdd(this.separators, value, values); + return this; + } + /** * Required - The maximum size of a chunk in words. This value cannot be higher * than 300 or lower than 20 (for @@ -259,6 +400,9 @@ public ChunkingSettings build() { protected static void setupChunkingSettingsDeserializer(ObjectDeserializer op) { op.add(Builder::strategy, JsonpDeserializer.stringDeserializer(), "strategy"); + op.add(Builder::separatorGroup, JsonpDeserializer.stringDeserializer(), "separator_group"); + op.add(Builder::separators, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "separators"); op.add(Builder::maxChunkSize, JsonpDeserializer.integerDeserializer(), "max_chunk_size"); op.add(Builder::overlap, JsonpDeserializer.integerDeserializer(), "overlap"); op.add(Builder::sentenceOverlap, JsonpDeserializer.integerDeserializer(), "sentence_overlap"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/TypeMapping.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/TypeMapping.java index dde04f111..2458388a0 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/TypeMapping.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/TypeMapping.java @@ -527,6 +527,7 @@ public final Builder dynamicTemplates(List> list) { *

* Adds one or more values to dynamicTemplates. */ + @SafeVarargs public final Builder dynamicTemplates(NamedValue value, NamedValue... values) { this.dynamicTemplates = _listAdd(this.dynamicTemplates, value, values); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java index 6ef0d1b3c..a70ae140f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java @@ -1688,6 +1688,7 @@ public final Builder indicesBoost(List> list) { *

* Adds one or more values to indicesBoost. */ + @SafeVarargs public final Builder indicesBoost(NamedValue value, NamedValue... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchRequest.java index b7839538e..f87f0ec9b 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchRequest.java @@ -1977,6 +1977,7 @@ public final Builder indicesBoost(List> list) { *

* Adds one or more values to indicesBoost. */ + @SafeVarargs public final Builder indicesBoost(NamedValue value, NamedValue... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/Highlight.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/Highlight.java index de9fe12d2..07d4936c4 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/Highlight.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/Highlight.java @@ -151,6 +151,7 @@ public final Builder fields(List> list) { *

* Adds one or more values to fields. */ + @SafeVarargs public final Builder fields(NamedValue value, NamedValue... values) { this.fields = _listAdd(this.fields, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/SearchRequestBody.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/SearchRequestBody.java index c974217fa..f8b37fb9b 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/SearchRequestBody.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/SearchRequestBody.java @@ -1157,6 +1157,7 @@ public final Builder indicesBoost(List> list) { *

* Adds one or more values to indicesBoost. */ + @SafeVarargs public final Builder indicesBoost(NamedValue value, NamedValue... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html index a03836d98..10e66b001 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html @@ -829,7 +829,7 @@ '_types.mapping.BinaryProperty': '_types/mapping/core.ts#L56-L58', '_types.mapping.BooleanProperty': '_types/mapping/core.ts#L60-L75', '_types.mapping.ByteNumberProperty': '_types/mapping/core.ts#L187-L190', -'_types.mapping.ChunkingSettings': '_types/mapping/ChunkingSettings.ts#L24-L32', +'_types.mapping.ChunkingSettings': '_types/mapping/ChunkingSettings.ts#L24-L36', '_types.mapping.CompletionProperty': '_types/mapping/specialized.ts#L33-L41', '_types.mapping.CompositeSubField': '_types/mapping/RuntimeFields.ts#L52-L54', '_types.mapping.ConstantKeywordProperty': '_types/mapping/specialized.ts#L50-L53', @@ -1434,7 +1434,7 @@ 'esql.list_queries.Body': 'esql/list_queries/ListQueriesResponse.ts#L24-L30', 'esql.list_queries.Request': 'esql/list_queries/ListQueriesRequest.ts#L22-L38', 'esql.list_queries.Response': 'esql/list_queries/ListQueriesResponse.ts#L32-L36', -'esql.query.Request': 'esql/query/QueryRequest.ts#L27-L113', +'esql.query.Request': 'esql/query/QueryRequest.ts#L27-L115', 'esql.query.Response': 'esql/query/QueryResponse.ts#L22-L25', 'features._types.Feature': 'features/_types/Feature.ts#L20-L23', 'features.get_features.Request': 'features/get_features/GetFeaturesRequest.ts#L23-L53', @@ -1819,26 +1819,30 @@ 'inference._types.AmazonBedrockServiceType': 'inference/_types/CommonTypes.ts#L441-L443', 'inference._types.AmazonBedrockTaskSettings': 'inference/_types/CommonTypes.ts#L410-L434', 'inference._types.AmazonBedrockTaskType': 'inference/_types/CommonTypes.ts#L436-L439', -'inference._types.AnthropicServiceSettings': 'inference/_types/CommonTypes.ts#L445-L461', -'inference._types.AnthropicServiceType': 'inference/_types/CommonTypes.ts#L494-L496', -'inference._types.AnthropicTaskSettings': 'inference/_types/CommonTypes.ts#L463-L488', -'inference._types.AnthropicTaskType': 'inference/_types/CommonTypes.ts#L490-L492', -'inference._types.AzureAiStudioServiceSettings': 'inference/_types/CommonTypes.ts#L498-L540', -'inference._types.AzureAiStudioServiceType': 'inference/_types/CommonTypes.ts#L577-L579', -'inference._types.AzureAiStudioTaskSettings': 'inference/_types/CommonTypes.ts#L542-L570', -'inference._types.AzureAiStudioTaskType': 'inference/_types/CommonTypes.ts#L572-L575', -'inference._types.AzureOpenAIServiceSettings': 'inference/_types/CommonTypes.ts#L581-L626', -'inference._types.AzureOpenAIServiceType': 'inference/_types/CommonTypes.ts#L641-L643', -'inference._types.AzureOpenAITaskSettings': 'inference/_types/CommonTypes.ts#L628-L634', -'inference._types.AzureOpenAITaskType': 'inference/_types/CommonTypes.ts#L636-L639', -'inference._types.CohereEmbeddingType': 'inference/_types/CommonTypes.ts#L700-L706', -'inference._types.CohereInputType': 'inference/_types/CommonTypes.ts#L708-L713', -'inference._types.CohereServiceSettings': 'inference/_types/CommonTypes.ts#L645-L688', -'inference._types.CohereServiceType': 'inference/_types/CommonTypes.ts#L696-L698', -'inference._types.CohereSimilarityType': 'inference/_types/CommonTypes.ts#L715-L719', -'inference._types.CohereTaskSettings': 'inference/_types/CommonTypes.ts#L727-L759', -'inference._types.CohereTaskType': 'inference/_types/CommonTypes.ts#L690-L694', -'inference._types.CohereTruncateType': 'inference/_types/CommonTypes.ts#L721-L725', +'inference._types.AmazonSageMakerApi': 'inference/_types/CommonTypes.ts#L501-L504', +'inference._types.AmazonSageMakerServiceSettings': 'inference/_types/CommonTypes.ts#L445-L499', +'inference._types.AmazonSageMakerServiceType': 'inference/_types/CommonTypes.ts#L584-L586', +'inference._types.AmazonSageMakerTaskSettings': 'inference/_types/CommonTypes.ts#L535-L564', +'inference._types.AnthropicServiceSettings': 'inference/_types/CommonTypes.ts#L588-L604', +'inference._types.AnthropicServiceType': 'inference/_types/CommonTypes.ts#L637-L639', +'inference._types.AnthropicTaskSettings': 'inference/_types/CommonTypes.ts#L606-L631', +'inference._types.AnthropicTaskType': 'inference/_types/CommonTypes.ts#L633-L635', +'inference._types.AzureAiStudioServiceSettings': 'inference/_types/CommonTypes.ts#L641-L683', +'inference._types.AzureAiStudioServiceType': 'inference/_types/CommonTypes.ts#L720-L722', +'inference._types.AzureAiStudioTaskSettings': 'inference/_types/CommonTypes.ts#L685-L713', +'inference._types.AzureAiStudioTaskType': 'inference/_types/CommonTypes.ts#L715-L718', +'inference._types.AzureOpenAIServiceSettings': 'inference/_types/CommonTypes.ts#L724-L769', +'inference._types.AzureOpenAIServiceType': 'inference/_types/CommonTypes.ts#L784-L786', +'inference._types.AzureOpenAITaskSettings': 'inference/_types/CommonTypes.ts#L771-L777', +'inference._types.AzureOpenAITaskType': 'inference/_types/CommonTypes.ts#L779-L782', +'inference._types.CohereEmbeddingType': 'inference/_types/CommonTypes.ts#L841-L847', +'inference._types.CohereInputType': 'inference/_types/CommonTypes.ts#L849-L854', +'inference._types.CohereServiceSettings': 'inference/_types/CommonTypes.ts#L788-L829', +'inference._types.CohereServiceType': 'inference/_types/CommonTypes.ts#L837-L839', +'inference._types.CohereSimilarityType': 'inference/_types/CommonTypes.ts#L856-L860', +'inference._types.CohereTaskSettings': 'inference/_types/CommonTypes.ts#L868-L900', +'inference._types.CohereTaskType': 'inference/_types/CommonTypes.ts#L831-L835', +'inference._types.CohereTruncateType': 'inference/_types/CommonTypes.ts#L862-L866', 'inference._types.CompletionInferenceResult': 'inference/_types/Results.ts#L84-L89', 'inference._types.CompletionResult': 'inference/_types/Results.ts#L77-L82', 'inference._types.CompletionTool': 'inference/_types/CommonTypes.ts#L278-L290', @@ -1847,72 +1851,73 @@ 'inference._types.CompletionToolFunction': 'inference/_types/CommonTypes.ts#L255-L276', 'inference._types.CompletionToolType': 'inference/_types/CommonTypes.ts#L118-L121', 'inference._types.ContentObject': 'inference/_types/CommonTypes.ts#L123-L135', -'inference._types.CustomRequestParams': 'inference/_types/CommonTypes.ts#L831-L842', -'inference._types.CustomResponseParams': 'inference/_types/CommonTypes.ts#L844-L982', -'inference._types.CustomServiceSettings': 'inference/_types/CommonTypes.ts#L761-L829', -'inference._types.CustomServiceType': 'inference/_types/CommonTypes.ts#L991-L993', -'inference._types.CustomTaskSettings': 'inference/_types/CommonTypes.ts#L995-L1009', -'inference._types.CustomTaskType': 'inference/_types/CommonTypes.ts#L984-L989', -'inference._types.DeepSeekServiceSettings': 'inference/_types/CommonTypes.ts#L1023-L1045', -'inference._types.DeepSeekServiceType': 'inference/_types/CommonTypes.ts#L1047-L1049', +'inference._types.CustomRequestParams': 'inference/_types/CommonTypes.ts#L972-L983', +'inference._types.CustomResponseParams': 'inference/_types/CommonTypes.ts#L985-L1123', +'inference._types.CustomServiceSettings': 'inference/_types/CommonTypes.ts#L902-L970', +'inference._types.CustomServiceType': 'inference/_types/CommonTypes.ts#L1132-L1134', +'inference._types.CustomTaskSettings': 'inference/_types/CommonTypes.ts#L1136-L1150', +'inference._types.CustomTaskType': 'inference/_types/CommonTypes.ts#L1125-L1130', +'inference._types.DeepSeekServiceSettings': 'inference/_types/CommonTypes.ts#L1164-L1186', +'inference._types.DeepSeekServiceType': 'inference/_types/CommonTypes.ts#L1188-L1190', 'inference._types.DeleteInferenceEndpointResult': 'inference/_types/Results.ts#L110-L115', -'inference._types.ElasticsearchServiceSettings': 'inference/_types/CommonTypes.ts#L1072-L1106', -'inference._types.ElasticsearchServiceType': 'inference/_types/CommonTypes.ts#L1122-L1124', -'inference._types.ElasticsearchTaskSettings': 'inference/_types/CommonTypes.ts#L1108-L1114', -'inference._types.ElasticsearchTaskType': 'inference/_types/CommonTypes.ts#L1116-L1120', -'inference._types.ElserServiceSettings': 'inference/_types/CommonTypes.ts#L1126-L1152', -'inference._types.ElserServiceType': 'inference/_types/CommonTypes.ts#L1158-L1160', -'inference._types.ElserTaskType': 'inference/_types/CommonTypes.ts#L1154-L1156', -'inference._types.GoogleAiServiceType': 'inference/_types/CommonTypes.ts#L1185-L1187', -'inference._types.GoogleAiStudioServiceSettings': 'inference/_types/CommonTypes.ts#L1162-L1178', -'inference._types.GoogleAiStudioTaskType': 'inference/_types/CommonTypes.ts#L1180-L1183', -'inference._types.GoogleVertexAIServiceSettings': 'inference/_types/CommonTypes.ts#L1189-L1215', -'inference._types.GoogleVertexAIServiceType': 'inference/_types/CommonTypes.ts#L1235-L1237', -'inference._types.GoogleVertexAITaskSettings': 'inference/_types/CommonTypes.ts#L1217-L1226', -'inference._types.GoogleVertexAITaskType': 'inference/_types/CommonTypes.ts#L1228-L1233', -'inference._types.HuggingFaceServiceSettings': 'inference/_types/CommonTypes.ts#L1239-L1271', -'inference._types.HuggingFaceServiceType': 'inference/_types/CommonTypes.ts#L1292-L1294', -'inference._types.HuggingFaceTaskSettings': 'inference/_types/CommonTypes.ts#L1273-L1283', -'inference._types.HuggingFaceTaskType': 'inference/_types/CommonTypes.ts#L1285-L1290', -'inference._types.InferenceChunkingSettings': 'inference/_types/Services.ts#L276-L305', -'inference._types.InferenceEndpoint': 'inference/_types/Services.ts#L44-L64', -'inference._types.InferenceEndpointInfo': 'inference/_types/Services.ts#L66-L78', -'inference._types.InferenceEndpointInfoAlibabaCloudAI': 'inference/_types/Services.ts#L79-L88', -'inference._types.InferenceEndpointInfoAmazonBedrock': 'inference/_types/Services.ts#L90-L99', -'inference._types.InferenceEndpointInfoAnthropic': 'inference/_types/Services.ts#L101-L110', -'inference._types.InferenceEndpointInfoAzureAIStudio': 'inference/_types/Services.ts#L112-L121', -'inference._types.InferenceEndpointInfoAzureOpenAI': 'inference/_types/Services.ts#L123-L132', -'inference._types.InferenceEndpointInfoCohere': 'inference/_types/Services.ts#L134-L143', -'inference._types.InferenceEndpointInfoCustom': 'inference/_types/Services.ts#L145-L154', -'inference._types.InferenceEndpointInfoDeepSeek': 'inference/_types/Services.ts#L155-L164', -'inference._types.InferenceEndpointInfoELSER': 'inference/_types/Services.ts#L177-L186', -'inference._types.InferenceEndpointInfoElasticsearch': 'inference/_types/Services.ts#L166-L175', -'inference._types.InferenceEndpointInfoGoogleAIStudio': 'inference/_types/Services.ts#L188-L197', -'inference._types.InferenceEndpointInfoGoogleVertexAI': 'inference/_types/Services.ts#L199-L208', -'inference._types.InferenceEndpointInfoHuggingFace': 'inference/_types/Services.ts#L210-L219', -'inference._types.InferenceEndpointInfoJinaAi': 'inference/_types/Services.ts#L221-L230', -'inference._types.InferenceEndpointInfoMistral': 'inference/_types/Services.ts#L232-L241', -'inference._types.InferenceEndpointInfoOpenAI': 'inference/_types/Services.ts#L243-L252', -'inference._types.InferenceEndpointInfoVoyageAI': 'inference/_types/Services.ts#L254-L263', -'inference._types.InferenceEndpointInfoWatsonx': 'inference/_types/Services.ts#L265-L274', +'inference._types.ElasticsearchServiceSettings': 'inference/_types/CommonTypes.ts#L1213-L1247', +'inference._types.ElasticsearchServiceType': 'inference/_types/CommonTypes.ts#L1263-L1265', +'inference._types.ElasticsearchTaskSettings': 'inference/_types/CommonTypes.ts#L1249-L1255', +'inference._types.ElasticsearchTaskType': 'inference/_types/CommonTypes.ts#L1257-L1261', +'inference._types.ElserServiceSettings': 'inference/_types/CommonTypes.ts#L1267-L1293', +'inference._types.ElserServiceType': 'inference/_types/CommonTypes.ts#L1299-L1301', +'inference._types.ElserTaskType': 'inference/_types/CommonTypes.ts#L1295-L1297', +'inference._types.GoogleAiServiceType': 'inference/_types/CommonTypes.ts#L1326-L1328', +'inference._types.GoogleAiStudioServiceSettings': 'inference/_types/CommonTypes.ts#L1303-L1319', +'inference._types.GoogleAiStudioTaskType': 'inference/_types/CommonTypes.ts#L1321-L1324', +'inference._types.GoogleVertexAIServiceSettings': 'inference/_types/CommonTypes.ts#L1330-L1356', +'inference._types.GoogleVertexAIServiceType': 'inference/_types/CommonTypes.ts#L1376-L1378', +'inference._types.GoogleVertexAITaskSettings': 'inference/_types/CommonTypes.ts#L1358-L1367', +'inference._types.GoogleVertexAITaskType': 'inference/_types/CommonTypes.ts#L1369-L1374', +'inference._types.HuggingFaceServiceSettings': 'inference/_types/CommonTypes.ts#L1380-L1412', +'inference._types.HuggingFaceServiceType': 'inference/_types/CommonTypes.ts#L1433-L1435', +'inference._types.HuggingFaceTaskSettings': 'inference/_types/CommonTypes.ts#L1414-L1424', +'inference._types.HuggingFaceTaskType': 'inference/_types/CommonTypes.ts#L1426-L1431', +'inference._types.InferenceChunkingSettings': 'inference/_types/Services.ts#L288-L344', +'inference._types.InferenceEndpoint': 'inference/_types/Services.ts#L45-L65', +'inference._types.InferenceEndpointInfo': 'inference/_types/Services.ts#L67-L79', +'inference._types.InferenceEndpointInfoAlibabaCloudAI': 'inference/_types/Services.ts#L80-L89', +'inference._types.InferenceEndpointInfoAmazonBedrock': 'inference/_types/Services.ts#L91-L100', +'inference._types.InferenceEndpointInfoAmazonSageMaker': 'inference/_types/Services.ts#L102-L111', +'inference._types.InferenceEndpointInfoAnthropic': 'inference/_types/Services.ts#L113-L122', +'inference._types.InferenceEndpointInfoAzureAIStudio': 'inference/_types/Services.ts#L124-L133', +'inference._types.InferenceEndpointInfoAzureOpenAI': 'inference/_types/Services.ts#L135-L144', +'inference._types.InferenceEndpointInfoCohere': 'inference/_types/Services.ts#L146-L155', +'inference._types.InferenceEndpointInfoCustom': 'inference/_types/Services.ts#L157-L166', +'inference._types.InferenceEndpointInfoDeepSeek': 'inference/_types/Services.ts#L167-L176', +'inference._types.InferenceEndpointInfoELSER': 'inference/_types/Services.ts#L189-L198', +'inference._types.InferenceEndpointInfoElasticsearch': 'inference/_types/Services.ts#L178-L187', +'inference._types.InferenceEndpointInfoGoogleAIStudio': 'inference/_types/Services.ts#L200-L209', +'inference._types.InferenceEndpointInfoGoogleVertexAI': 'inference/_types/Services.ts#L211-L220', +'inference._types.InferenceEndpointInfoHuggingFace': 'inference/_types/Services.ts#L222-L231', +'inference._types.InferenceEndpointInfoJinaAi': 'inference/_types/Services.ts#L233-L242', +'inference._types.InferenceEndpointInfoMistral': 'inference/_types/Services.ts#L244-L253', +'inference._types.InferenceEndpointInfoOpenAI': 'inference/_types/Services.ts#L255-L264', +'inference._types.InferenceEndpointInfoVoyageAI': 'inference/_types/Services.ts#L266-L275', +'inference._types.InferenceEndpointInfoWatsonx': 'inference/_types/Services.ts#L277-L286', 'inference._types.InferenceResult': 'inference/_types/Results.ts#L117-L128', -'inference._types.JinaAIServiceSettings': 'inference/_types/CommonTypes.ts#L1296-L1325', -'inference._types.JinaAIServiceType': 'inference/_types/CommonTypes.ts#L1355-L1357', -'inference._types.JinaAISimilarityType': 'inference/_types/CommonTypes.ts#L1359-L1363', -'inference._types.JinaAITaskSettings': 'inference/_types/CommonTypes.ts#L1327-L1348', -'inference._types.JinaAITaskType': 'inference/_types/CommonTypes.ts#L1350-L1353', -'inference._types.JinaAITextEmbeddingTask': 'inference/_types/CommonTypes.ts#L1365-L1370', +'inference._types.JinaAIServiceSettings': 'inference/_types/CommonTypes.ts#L1437-L1466', +'inference._types.JinaAIServiceType': 'inference/_types/CommonTypes.ts#L1496-L1498', +'inference._types.JinaAISimilarityType': 'inference/_types/CommonTypes.ts#L1500-L1504', +'inference._types.JinaAITaskSettings': 'inference/_types/CommonTypes.ts#L1468-L1489', +'inference._types.JinaAITaskType': 'inference/_types/CommonTypes.ts#L1491-L1494', +'inference._types.JinaAITextEmbeddingTask': 'inference/_types/CommonTypes.ts#L1506-L1511', 'inference._types.Message': 'inference/_types/CommonTypes.ts#L174-L228', 'inference._types.MessageContent': 'inference/_types/CommonTypes.ts#L169-L172', -'inference._types.MistralServiceSettings': 'inference/_types/CommonTypes.ts#L1372-L1399', -'inference._types.MistralServiceType': 'inference/_types/CommonTypes.ts#L1407-L1409', -'inference._types.MistralTaskType': 'inference/_types/CommonTypes.ts#L1401-L1405', -'inference._types.OpenAIServiceSettings': 'inference/_types/CommonTypes.ts#L1411-L1453', -'inference._types.OpenAIServiceType': 'inference/_types/CommonTypes.ts#L1469-L1471', -'inference._types.OpenAITaskSettings': 'inference/_types/CommonTypes.ts#L1455-L1461', -'inference._types.OpenAITaskType': 'inference/_types/CommonTypes.ts#L1463-L1467', +'inference._types.MistralServiceSettings': 'inference/_types/CommonTypes.ts#L1513-L1540', +'inference._types.MistralServiceType': 'inference/_types/CommonTypes.ts#L1548-L1550', +'inference._types.MistralTaskType': 'inference/_types/CommonTypes.ts#L1542-L1546', +'inference._types.OpenAIServiceSettings': 'inference/_types/CommonTypes.ts#L1552-L1594', +'inference._types.OpenAIServiceType': 'inference/_types/CommonTypes.ts#L1610-L1612', +'inference._types.OpenAITaskSettings': 'inference/_types/CommonTypes.ts#L1596-L1602', +'inference._types.OpenAITaskType': 'inference/_types/CommonTypes.ts#L1604-L1608', 'inference._types.RankedDocument': 'inference/_types/Results.ts#L91-L101', -'inference._types.RateLimitSetting': 'inference/_types/Services.ts#L311-L337', +'inference._types.RateLimitSetting': 'inference/_types/Services.ts#L350-L376', 'inference._types.RequestChatCompletion': 'inference/_types/CommonTypes.ts#L25-L97', 'inference._types.RerankedInferenceResult': 'inference/_types/Results.ts#L103-L108', 'inference._types.SparseEmbeddingInferenceResult': 'inference/_types/Results.ts#L40-L45', @@ -1920,34 +1925,35 @@ 'inference._types.TaskType': 'inference/_types/TaskType.ts#L20-L29', 'inference._types.TaskTypeAlibabaCloudAI': 'inference/_types/TaskType.ts#L36-L41', 'inference._types.TaskTypeAmazonBedrock': 'inference/_types/TaskType.ts#L43-L46', -'inference._types.TaskTypeAnthropic': 'inference/_types/TaskType.ts#L48-L50', -'inference._types.TaskTypeAzureAIStudio': 'inference/_types/TaskType.ts#L52-L55', -'inference._types.TaskTypeAzureOpenAI': 'inference/_types/TaskType.ts#L57-L60', -'inference._types.TaskTypeCohere': 'inference/_types/TaskType.ts#L62-L66', -'inference._types.TaskTypeCustom': 'inference/_types/TaskType.ts#L68-L73', -'inference._types.TaskTypeDeepSeek': 'inference/_types/TaskType.ts#L75-L78', -'inference._types.TaskTypeELSER': 'inference/_types/TaskType.ts#L86-L88', -'inference._types.TaskTypeElasticsearch': 'inference/_types/TaskType.ts#L80-L84', -'inference._types.TaskTypeGoogleAIStudio': 'inference/_types/TaskType.ts#L90-L93', -'inference._types.TaskTypeGoogleVertexAI': 'inference/_types/TaskType.ts#L95-L98', -'inference._types.TaskTypeHuggingFace': 'inference/_types/TaskType.ts#L100-L105', +'inference._types.TaskTypeAmazonSageMaker': 'inference/_types/TaskType.ts#L48-L54', +'inference._types.TaskTypeAnthropic': 'inference/_types/TaskType.ts#L56-L58', +'inference._types.TaskTypeAzureAIStudio': 'inference/_types/TaskType.ts#L60-L63', +'inference._types.TaskTypeAzureOpenAI': 'inference/_types/TaskType.ts#L65-L68', +'inference._types.TaskTypeCohere': 'inference/_types/TaskType.ts#L70-L74', +'inference._types.TaskTypeCustom': 'inference/_types/TaskType.ts#L76-L81', +'inference._types.TaskTypeDeepSeek': 'inference/_types/TaskType.ts#L83-L86', +'inference._types.TaskTypeELSER': 'inference/_types/TaskType.ts#L94-L96', +'inference._types.TaskTypeElasticsearch': 'inference/_types/TaskType.ts#L88-L92', +'inference._types.TaskTypeGoogleAIStudio': 'inference/_types/TaskType.ts#L98-L101', +'inference._types.TaskTypeGoogleVertexAI': 'inference/_types/TaskType.ts#L103-L106', +'inference._types.TaskTypeHuggingFace': 'inference/_types/TaskType.ts#L108-L113', 'inference._types.TaskTypeJinaAi': 'inference/_types/TaskType.ts#L31-L34', -'inference._types.TaskTypeMistral': 'inference/_types/TaskType.ts#L107-L111', -'inference._types.TaskTypeOpenAI': 'inference/_types/TaskType.ts#L113-L117', -'inference._types.TaskTypeVoyageAI': 'inference/_types/TaskType.ts#L119-L122', -'inference._types.TaskTypeWatsonx': 'inference/_types/TaskType.ts#L124-L128', +'inference._types.TaskTypeMistral': 'inference/_types/TaskType.ts#L115-L119', +'inference._types.TaskTypeOpenAI': 'inference/_types/TaskType.ts#L121-L125', +'inference._types.TaskTypeVoyageAI': 'inference/_types/TaskType.ts#L127-L130', +'inference._types.TaskTypeWatsonx': 'inference/_types/TaskType.ts#L132-L136', 'inference._types.TextEmbeddingByteResult': 'inference/_types/Results.ts#L53-L58', 'inference._types.TextEmbeddingInferenceResult': 'inference/_types/Results.ts#L67-L75', 'inference._types.TextEmbeddingResult': 'inference/_types/Results.ts#L60-L65', 'inference._types.ToolCall': 'inference/_types/CommonTypes.ts#L151-L167', 'inference._types.ToolCallFunction': 'inference/_types/CommonTypes.ts#L137-L149', -'inference._types.VoyageAIServiceSettings': 'inference/_types/CommonTypes.ts#L1473-L1504', -'inference._types.VoyageAIServiceType': 'inference/_types/CommonTypes.ts#L1537-L1539', -'inference._types.VoyageAITaskSettings': 'inference/_types/CommonTypes.ts#L1506-L1530', -'inference._types.VoyageAITaskType': 'inference/_types/CommonTypes.ts#L1532-L1535', -'inference._types.WatsonxServiceSettings': 'inference/_types/CommonTypes.ts#L1541-L1579', -'inference._types.WatsonxServiceType': 'inference/_types/CommonTypes.ts#L1587-L1589', -'inference._types.WatsonxTaskType': 'inference/_types/CommonTypes.ts#L1581-L1585', +'inference._types.VoyageAIServiceSettings': 'inference/_types/CommonTypes.ts#L1614-L1645', +'inference._types.VoyageAIServiceType': 'inference/_types/CommonTypes.ts#L1678-L1680', +'inference._types.VoyageAITaskSettings': 'inference/_types/CommonTypes.ts#L1647-L1671', +'inference._types.VoyageAITaskType': 'inference/_types/CommonTypes.ts#L1673-L1676', +'inference._types.WatsonxServiceSettings': 'inference/_types/CommonTypes.ts#L1682-L1720', +'inference._types.WatsonxServiceType': 'inference/_types/CommonTypes.ts#L1728-L1730', +'inference._types.WatsonxTaskType': 'inference/_types/CommonTypes.ts#L1722-L1726', 'inference.chat_completion_unified.Request': 'inference/chat_completion_unified/UnifiedRequest.ts#L24-L61', 'inference.chat_completion_unified.Response': 'inference/chat_completion_unified/UnifiedResponse.ts#L22-L25', 'inference.completion.Request': 'inference/completion/CompletionRequest.ts#L25-L63', @@ -1958,12 +1964,14 @@ 'inference.get.Response': 'inference/get/GetResponse.ts#L22-L26', 'inference.inference.Request': 'inference/inference/InferenceRequest.ts#L26-L104', 'inference.inference.Response': 'inference/inference/InferenceResponse.ts#L22-L25', -'inference.put.Request': 'inference/put/PutRequest.ts#L26-L87', +'inference.put.Request': 'inference/put/PutRequest.ts#L26-L89', 'inference.put.Response': 'inference/put/PutResponse.ts#L22-L25', 'inference.put_alibabacloud.Request': 'inference/put_alibabacloud/PutAlibabaCloudRequest.ts#L31-L85', 'inference.put_alibabacloud.Response': 'inference/put_alibabacloud/PutAlibabaCloudResponse.ts#L22-L25', 'inference.put_amazonbedrock.Request': 'inference/put_amazonbedrock/PutAmazonBedrockRequest.ts#L31-L88', 'inference.put_amazonbedrock.Response': 'inference/put_amazonbedrock/PutAmazonBedrockResponse.ts#L22-L25', +'inference.put_amazonsagemaker.Request': 'inference/put_amazonsagemaker/PutAmazonSageMakerRequest.ts#L31-L86', +'inference.put_amazonsagemaker.Response': 'inference/put_amazonsagemaker/PutAmazonSageMakerResponse.ts#L22-L25', 'inference.put_anthropic.Request': 'inference/put_anthropic/PutAnthropicRequest.ts#L31-L86', 'inference.put_anthropic.Response': 'inference/put_anthropic/PutAnthropicResponse.ts#L22-L25', 'inference.put_azureaistudio.Request': 'inference/put_azureaistudio/PutAzureAiStudioRequest.ts#L31-L85', @@ -3046,9 +3054,9 @@ 'sql.get_async.Response': 'sql/get_async/SqlGetAsyncResponse.ts#L23-L60', 'sql.get_async_status.Request': 'sql/get_async_status/SqlGetAsyncStatusRequest.ts#L23-L45', 'sql.get_async_status.Response': 'sql/get_async_status/SqlGetAsyncStatusResponse.ts#L23-L55', -'sql.query.Request': 'sql/query/QuerySqlRequest.ts#L28-L152', +'sql.query.Request': 'sql/query/QuerySqlRequest.ts#L27-L151', 'sql.query.Response': 'sql/query/QuerySqlResponse.ts#L23-L60', -'sql.query.SqlFormat': 'sql/query/QuerySqlRequest.ts#L154-L162', +'sql.query.SqlFormat': 'sql/query/QuerySqlRequest.ts#L153-L161', 'sql.translate.Request': 'sql/translate/TranslateSqlRequest.ts#L25-L65', 'sql.translate.Response': 'sql/translate/TranslateSqlResponse.ts#L27-L37', 'ssl.certificates.CertificateInformation': 'ssl/certificates/types.ts#L22-L57', @@ -3340,10 +3348,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/76cd5c918a1c3aeb4d26f76a6683bba7a9e79289/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/806407ac4f3233b0011a63a877d7e443f730b6df/specification/" + (paths[hash] || ""); - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/QueryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/QueryRequest.java index d94014924..f15b61a53 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/QueryRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/esql/QueryRequest.java @@ -197,6 +197,10 @@ public final Query filter() { /** * A short version of the Accept header, e.g. json, yaml. *

+ * csv, tsv, and txt formats will return + * results in a tabular format, excluding other metadata fields from the + * response. + *

* API name: {@code format} */ @Nullable @@ -471,6 +475,10 @@ public final Builder filter(QueryVariant value) { /** * A short version of the Accept header, e.g. json, yaml. *

+ * csv, tsv, and txt formats will return + * results in a tabular format, excluding other metadata fields from the + * response. + *

* API name: {@code format} */ public final Builder format(@Nullable EsqlFormat value) { diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/fleet/FleetSearchRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/fleet/FleetSearchRequest.java index 6a0e2fcef..7f11a2fcc 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/fleet/FleetSearchRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/fleet/FleetSearchRequest.java @@ -1552,6 +1552,7 @@ public final Builder indicesBoost(List> list) { *

* Adds one or more values to indicesBoost. */ + @SafeVarargs public final Builder indicesBoost(NamedValue value, NamedValue... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesAsyncClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesAsyncClient.java index 1728d1d1f..0134b72de 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesAsyncClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesAsyncClient.java @@ -2856,7 +2856,7 @@ public final CompletableFuture putIndexTemplate( *

* Learn how to use the update mapping API with practical examples in the * Update + * "https://www.elastic.co/docs/manage-data/data-store/mapping/update-mappings-examples">Update * mapping API examples guide. * * @see putMapping(PutMappingRequest reques *

* Learn how to use the update mapping API with practical examples in the * Update + * "https://www.elastic.co/docs/manage-data/data-store/mapping/update-mappings-examples">Update * mapping API examples guide. * * @param fn diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesClient.java index 04007c511..52fd14e1f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/ElasticsearchIndicesClient.java @@ -2908,7 +2908,7 @@ public final PutIndexTemplateResponse putIndexTemplate( *

* Learn how to use the update mapping API with practical examples in the * Update + * "https://www.elastic.co/docs/manage-data/data-store/mapping/update-mappings-examples">Update * mapping API examples guide. * * @see * Learn how to use the update mapping API with practical examples in the * Update + * "https://www.elastic.co/docs/manage-data/data-store/mapping/update-mappings-examples">Update * mapping API examples guide. * * @param fn diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutMappingRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutMappingRequest.java index 0c36e2e3d..47444f793 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutMappingRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutMappingRequest.java @@ -85,7 +85,7 @@ *

* Learn how to use the update mapping API with practical examples in the * Update + * "https://www.elastic.co/docs/manage-data/data-store/mapping/update-mappings-examples">Update * mapping API examples guide. * * @see API @@ -690,6 +690,7 @@ public final Builder dynamicTemplates(List> list) { *

* Adds one or more values to dynamicTemplates. */ + @SafeVarargs public final Builder dynamicTemplates(NamedValue value, NamedValue... values) { this.dynamicTemplates = _listAdd(this.dynamicTemplates, value, values); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerApi.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerApi.java new file mode 100644 index 000000000..687f84344 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerApi.java @@ -0,0 +1,67 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.elasticsearch.inference; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum AmazonSageMakerApi implements JsonEnum { + Openai("openai"), + + Elastic("elastic"), + + ; + + private final String jsonValue; + + AmazonSageMakerApi(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + AmazonSageMakerApi.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerServiceSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerServiceSettings.java new file mode 100644 index 000000000..e79a22522 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerServiceSettings.java @@ -0,0 +1,464 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.elasticsearch.inference; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.JsonpSerializable; +import co.elastic.clients.json.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Integer; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: inference._types.AmazonSageMakerServiceSettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class AmazonSageMakerServiceSettings implements JsonpSerializable { + private final String accessKey; + + private final String endpointName; + + private final AmazonSageMakerApi api; + + private final String region; + + private final String secretKey; + + @Nullable + private final String targetModel; + + @Nullable + private final String targetContainerHostname; + + @Nullable + private final String inferenceComponentName; + + @Nullable + private final Integer batchSize; + + @Nullable + private final Integer dimensions; + + // --------------------------------------------------------------------------------------------- + + private AmazonSageMakerServiceSettings(Builder builder) { + + this.accessKey = ApiTypeHelper.requireNonNull(builder.accessKey, this, "accessKey"); + this.endpointName = ApiTypeHelper.requireNonNull(builder.endpointName, this, "endpointName"); + this.api = ApiTypeHelper.requireNonNull(builder.api, this, "api"); + this.region = ApiTypeHelper.requireNonNull(builder.region, this, "region"); + this.secretKey = ApiTypeHelper.requireNonNull(builder.secretKey, this, "secretKey"); + this.targetModel = builder.targetModel; + this.targetContainerHostname = builder.targetContainerHostname; + this.inferenceComponentName = builder.inferenceComponentName; + this.batchSize = builder.batchSize; + this.dimensions = builder.dimensions; + + } + + public static AmazonSageMakerServiceSettings of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - A valid AWS access key that has permissions to use Amazon + * SageMaker and access to models for invoking requests. + *

+ * API name: {@code access_key} + */ + public final String accessKey() { + return this.accessKey; + } + + /** + * Required - The name of the SageMaker endpoint. + *

+ * API name: {@code endpoint_name} + */ + public final String endpointName() { + return this.endpointName; + } + + /** + * Required - The API format to use when calling SageMaker. Elasticsearch will + * convert the POST _inference request to this data format when invoking the + * SageMaker endpoint. + *

+ * API name: {@code api} + */ + public final AmazonSageMakerApi api() { + return this.api; + } + + /** + * Required - The region that your endpoint or Amazon Resource Name (ARN) is + * deployed in. The list of available regions per model can be found in the + * Amazon SageMaker documentation. + *

+ * API name: {@code region} + */ + public final String region() { + return this.region; + } + + /** + * Required - A valid AWS secret key that is paired with the + * access_key. For information about creating and managing access + * and secret keys, refer to the AWS documentation. + *

+ * API name: {@code secret_key} + */ + public final String secretKey() { + return this.secretKey; + } + + /** + * The model ID when calling a multi-model endpoint. + *

+ * API name: {@code target_model} + */ + @Nullable + public final String targetModel() { + return this.targetModel; + } + + /** + * The container to directly invoke when calling a multi-container endpoint. + *

+ * API name: {@code target_container_hostname} + */ + @Nullable + public final String targetContainerHostname() { + return this.targetContainerHostname; + } + + /** + * The inference component to directly invoke when calling a multi-component + * endpoint. + *

+ * API name: {@code inference_component_name} + */ + @Nullable + public final String inferenceComponentName() { + return this.inferenceComponentName; + } + + /** + * The maximum number of inputs in each batch. This value is used by inference + * ingestion pipelines when processing semantic values. It correlates to the + * number of times the SageMaker endpoint is invoked (one per batch of input). + *

+ * API name: {@code batch_size} + */ + @Nullable + public final Integer batchSize() { + return this.batchSize; + } + + /** + * The number of dimensions returned by the text embedding models. If this value + * is not provided, then it is guessed by making invoking the endpoint for the + * text_embedding task. + *

+ * API name: {@code dimensions} + */ + @Nullable + public final Integer dimensions() { + return this.dimensions; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("access_key"); + generator.write(this.accessKey); + + generator.writeKey("endpoint_name"); + generator.write(this.endpointName); + + generator.writeKey("api"); + this.api.serialize(generator, mapper); + generator.writeKey("region"); + generator.write(this.region); + + generator.writeKey("secret_key"); + generator.write(this.secretKey); + + if (this.targetModel != null) { + generator.writeKey("target_model"); + generator.write(this.targetModel); + + } + if (this.targetContainerHostname != null) { + generator.writeKey("target_container_hostname"); + generator.write(this.targetContainerHostname); + + } + if (this.inferenceComponentName != null) { + generator.writeKey("inference_component_name"); + generator.write(this.inferenceComponentName); + + } + if (this.batchSize != null) { + generator.writeKey("batch_size"); + generator.write(this.batchSize); + + } + if (this.dimensions != null) { + generator.writeKey("dimensions"); + generator.write(this.dimensions); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link AmazonSageMakerServiceSettings}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + private String accessKey; + + private String endpointName; + + private AmazonSageMakerApi api; + + private String region; + + private String secretKey; + + @Nullable + private String targetModel; + + @Nullable + private String targetContainerHostname; + + @Nullable + private String inferenceComponentName; + + @Nullable + private Integer batchSize; + + @Nullable + private Integer dimensions; + + /** + * Required - A valid AWS access key that has permissions to use Amazon + * SageMaker and access to models for invoking requests. + *

+ * API name: {@code access_key} + */ + public final Builder accessKey(String value) { + this.accessKey = value; + return this; + } + + /** + * Required - The name of the SageMaker endpoint. + *

+ * API name: {@code endpoint_name} + */ + public final Builder endpointName(String value) { + this.endpointName = value; + return this; + } + + /** + * Required - The API format to use when calling SageMaker. Elasticsearch will + * convert the POST _inference request to this data format when invoking the + * SageMaker endpoint. + *

+ * API name: {@code api} + */ + public final Builder api(AmazonSageMakerApi value) { + this.api = value; + return this; + } + + /** + * Required - The region that your endpoint or Amazon Resource Name (ARN) is + * deployed in. The list of available regions per model can be found in the + * Amazon SageMaker documentation. + *

+ * API name: {@code region} + */ + public final Builder region(String value) { + this.region = value; + return this; + } + + /** + * Required - A valid AWS secret key that is paired with the + * access_key. For information about creating and managing access + * and secret keys, refer to the AWS documentation. + *

+ * API name: {@code secret_key} + */ + public final Builder secretKey(String value) { + this.secretKey = value; + return this; + } + + /** + * The model ID when calling a multi-model endpoint. + *

+ * API name: {@code target_model} + */ + public final Builder targetModel(@Nullable String value) { + this.targetModel = value; + return this; + } + + /** + * The container to directly invoke when calling a multi-container endpoint. + *

+ * API name: {@code target_container_hostname} + */ + public final Builder targetContainerHostname(@Nullable String value) { + this.targetContainerHostname = value; + return this; + } + + /** + * The inference component to directly invoke when calling a multi-component + * endpoint. + *

+ * API name: {@code inference_component_name} + */ + public final Builder inferenceComponentName(@Nullable String value) { + this.inferenceComponentName = value; + return this; + } + + /** + * The maximum number of inputs in each batch. This value is used by inference + * ingestion pipelines when processing semantic values. It correlates to the + * number of times the SageMaker endpoint is invoked (one per batch of input). + *

+ * API name: {@code batch_size} + */ + public final Builder batchSize(@Nullable Integer value) { + this.batchSize = value; + return this; + } + + /** + * The number of dimensions returned by the text embedding models. If this value + * is not provided, then it is guessed by making invoking the endpoint for the + * text_embedding task. + *

+ * API name: {@code dimensions} + */ + public final Builder dimensions(@Nullable Integer value) { + this.dimensions = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link AmazonSageMakerServiceSettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public AmazonSageMakerServiceSettings build() { + _checkSingleUse(); + + return new AmazonSageMakerServiceSettings(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link AmazonSageMakerServiceSettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, AmazonSageMakerServiceSettings::setupAmazonSageMakerServiceSettingsDeserializer); + + protected static void setupAmazonSageMakerServiceSettingsDeserializer( + ObjectDeserializer op) { + + op.add(Builder::accessKey, JsonpDeserializer.stringDeserializer(), "access_key"); + op.add(Builder::endpointName, JsonpDeserializer.stringDeserializer(), "endpoint_name"); + op.add(Builder::api, AmazonSageMakerApi._DESERIALIZER, "api"); + op.add(Builder::region, JsonpDeserializer.stringDeserializer(), "region"); + op.add(Builder::secretKey, JsonpDeserializer.stringDeserializer(), "secret_key"); + op.add(Builder::targetModel, JsonpDeserializer.stringDeserializer(), "target_model"); + op.add(Builder::targetContainerHostname, JsonpDeserializer.stringDeserializer(), "target_container_hostname"); + op.add(Builder::inferenceComponentName, JsonpDeserializer.stringDeserializer(), "inference_component_name"); + op.add(Builder::batchSize, JsonpDeserializer.integerDeserializer(), "batch_size"); + op.add(Builder::dimensions, JsonpDeserializer.integerDeserializer(), "dimensions"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerServiceType.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerServiceType.java new file mode 100644 index 000000000..09615988c --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerServiceType.java @@ -0,0 +1,65 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.elasticsearch.inference; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum AmazonSageMakerServiceType implements JsonEnum { + AmazonSagemaker("amazon_sagemaker"), + + ; + + private final String jsonValue; + + AmazonSageMakerServiceType(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + AmazonSageMakerServiceType.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerTaskSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerTaskSettings.java new file mode 100644 index 000000000..e6962eec5 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/AmazonSageMakerTaskSettings.java @@ -0,0 +1,310 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.elasticsearch.inference; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.JsonpSerializable; +import co.elastic.clients.json.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: inference._types.AmazonSageMakerTaskSettings + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class AmazonSageMakerTaskSettings implements JsonpSerializable { + @Nullable + private final String customAttributes; + + @Nullable + private final String enableExplanations; + + @Nullable + private final String inferenceId; + + @Nullable + private final String sessionId; + + @Nullable + private final String targetVariant; + + // --------------------------------------------------------------------------------------------- + + private AmazonSageMakerTaskSettings(Builder builder) { + + this.customAttributes = builder.customAttributes; + this.enableExplanations = builder.enableExplanations; + this.inferenceId = builder.inferenceId; + this.sessionId = builder.sessionId; + this.targetVariant = builder.targetVariant; + + } + + public static AmazonSageMakerTaskSettings of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The AWS custom attributes passed verbatim through to the model running in the + * SageMaker Endpoint. Values will be returned in the + * X-elastic-sagemaker-custom-attributes header. + *

+ * API name: {@code custom_attributes} + */ + @Nullable + public final String customAttributes() { + return this.customAttributes; + } + + /** + * The optional JMESPath expression used to override the EnableExplanations + * provided during endpoint creation. + *

+ * API name: {@code enable_explanations} + */ + @Nullable + public final String enableExplanations() { + return this.enableExplanations; + } + + /** + * The capture data ID when enabled in the endpoint. + *

+ * API name: {@code inference_id} + */ + @Nullable + public final String inferenceId() { + return this.inferenceId; + } + + /** + * The stateful session identifier for a new or existing session. New sessions + * will be returned in the X-elastic-sagemaker-new-session-id + * header. Closed sessions will be returned in the + * X-elastic-sagemaker-closed-session-id header. + *

+ * API name: {@code session_id} + */ + @Nullable + public final String sessionId() { + return this.sessionId; + } + + /** + * Specifies the variant when running with multi-variant Endpoints. + *

+ * API name: {@code target_variant} + */ + @Nullable + public final String targetVariant() { + return this.targetVariant; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.customAttributes != null) { + generator.writeKey("custom_attributes"); + generator.write(this.customAttributes); + + } + if (this.enableExplanations != null) { + generator.writeKey("enable_explanations"); + generator.write(this.enableExplanations); + + } + if (this.inferenceId != null) { + generator.writeKey("inference_id"); + generator.write(this.inferenceId); + + } + if (this.sessionId != null) { + generator.writeKey("session_id"); + generator.write(this.sessionId); + + } + if (this.targetVariant != null) { + generator.writeKey("target_variant"); + generator.write(this.targetVariant); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link AmazonSageMakerTaskSettings}. + */ + + public static class Builder extends WithJsonObjectBuilderBase + implements + ObjectBuilder { + @Nullable + private String customAttributes; + + @Nullable + private String enableExplanations; + + @Nullable + private String inferenceId; + + @Nullable + private String sessionId; + + @Nullable + private String targetVariant; + + /** + * The AWS custom attributes passed verbatim through to the model running in the + * SageMaker Endpoint. Values will be returned in the + * X-elastic-sagemaker-custom-attributes header. + *

+ * API name: {@code custom_attributes} + */ + public final Builder customAttributes(@Nullable String value) { + this.customAttributes = value; + return this; + } + + /** + * The optional JMESPath expression used to override the EnableExplanations + * provided during endpoint creation. + *

+ * API name: {@code enable_explanations} + */ + public final Builder enableExplanations(@Nullable String value) { + this.enableExplanations = value; + return this; + } + + /** + * The capture data ID when enabled in the endpoint. + *

+ * API name: {@code inference_id} + */ + public final Builder inferenceId(@Nullable String value) { + this.inferenceId = value; + return this; + } + + /** + * The stateful session identifier for a new or existing session. New sessions + * will be returned in the X-elastic-sagemaker-new-session-id + * header. Closed sessions will be returned in the + * X-elastic-sagemaker-closed-session-id header. + *

+ * API name: {@code session_id} + */ + public final Builder sessionId(@Nullable String value) { + this.sessionId = value; + return this; + } + + /** + * Specifies the variant when running with multi-variant Endpoints. + *

+ * API name: {@code target_variant} + */ + public final Builder targetVariant(@Nullable String value) { + this.targetVariant = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link AmazonSageMakerTaskSettings}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public AmazonSageMakerTaskSettings build() { + _checkSingleUse(); + + return new AmazonSageMakerTaskSettings(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link AmazonSageMakerTaskSettings} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, AmazonSageMakerTaskSettings::setupAmazonSageMakerTaskSettingsDeserializer); + + protected static void setupAmazonSageMakerTaskSettingsDeserializer( + ObjectDeserializer op) { + + op.add(Builder::customAttributes, JsonpDeserializer.stringDeserializer(), "custom_attributes"); + op.add(Builder::enableExplanations, JsonpDeserializer.stringDeserializer(), "enable_explanations"); + op.add(Builder::inferenceId, JsonpDeserializer.stringDeserializer(), "inference_id"); + op.add(Builder::sessionId, JsonpDeserializer.stringDeserializer(), "session_id"); + op.add(Builder::targetVariant, JsonpDeserializer.stringDeserializer(), "target_variant"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CohereServiceSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CohereServiceSettings.java index 424f7fe3a..5b2506475 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CohereServiceSettings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CohereServiceSettings.java @@ -65,7 +65,6 @@ public class CohereServiceSettings implements JsonpSerializable { @Nullable private final CohereEmbeddingType embeddingType; - @Nullable private final String modelId; @Nullable @@ -80,7 +79,7 @@ private CohereServiceSettings(Builder builder) { this.apiKey = ApiTypeHelper.requireNonNull(builder.apiKey, this, "apiKey"); this.embeddingType = builder.embeddingType; - this.modelId = builder.modelId; + this.modelId = ApiTypeHelper.requireNonNull(builder.modelId, this, "modelId"); this.rateLimit = builder.rateLimit; this.similarity = builder.similarity; @@ -123,7 +122,7 @@ public final CohereEmbeddingType embeddingType() { } /** - * For a completion, rerank, or + * Required - For a completion, rerank, or * text_embedding task, the name of the model to use for the * inference task. *

*

- * The default value for a text embedding task is - * embed-english-v2.0. - *

* API name: {@code model_id} */ - @Nullable public final String modelId() { return this.modelId; } @@ -190,11 +185,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("embedding_type"); this.embeddingType.serialize(generator, mapper); } - if (this.modelId != null) { - generator.writeKey("model_id"); - generator.write(this.modelId); + generator.writeKey("model_id"); + generator.write(this.modelId); - } if (this.rateLimit != null) { generator.writeKey("rate_limit"); this.rateLimit.serialize(generator, mapper); @@ -226,7 +219,6 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private CohereEmbeddingType embeddingType; - @Nullable private String modelId; @Nullable @@ -269,7 +261,7 @@ public final Builder embeddingType(@Nullable CohereEmbeddingType value) { } /** - * For a completion, rerank, or + * Required - For a completion, rerank, or * text_embedding task, the name of the model to use for the * inference task. *

*

- * The default value for a text embedding task is - * embed-english-v2.0. - *

* API name: {@code model_id} */ - public final Builder modelId(@Nullable String value) { + public final Builder modelId(String value) { this.modelId = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CohereTaskSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CohereTaskSettings.java index 1b364cb6a..5b2c99614 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CohereTaskSettings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/CohereTaskSettings.java @@ -26,6 +26,7 @@ import co.elastic.clients.json.JsonpUtils; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; @@ -60,7 +61,6 @@ */ @JsonpDeserializable public class CohereTaskSettings implements JsonpSerializable { - @Nullable private final CohereInputType inputType; @Nullable @@ -76,7 +76,7 @@ public class CohereTaskSettings implements JsonpSerializable { private CohereTaskSettings(Builder builder) { - this.inputType = builder.inputType; + this.inputType = ApiTypeHelper.requireNonNull(builder.inputType, this, "inputType"); this.returnDocuments = builder.returnDocuments; this.topN = builder.topN; this.truncate = builder.truncate; @@ -88,8 +88,8 @@ public static CohereTaskSettings of(Functiontext_embedding task, the type of input passed to the - * model. Valid values are: + * Required - For a text_embedding task, the type of input passed + * to the model. Valid values are: *

* * @param fn @@ -524,6 +536,45 @@ public final CompletableFuture putAmazonbedrock( return putAmazonbedrock(fn.apply(new PutAmazonbedrockRequest.Builder()).build()); } + // ----- Endpoint: inference.put_amazonsagemaker + + /** + * Create an Amazon SageMaker inference endpoint. + *

+ * Create an inference endpoint to perform an inference task with the + * amazon_sagemaker service. + * + * @see Documentation + * on elastic.co + */ + + public CompletableFuture putAmazonsagemaker(PutAmazonsagemakerRequest request) { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) PutAmazonsagemakerRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Create an Amazon SageMaker inference endpoint. + *

+ * Create an inference endpoint to perform an inference task with the + * amazon_sagemaker service. + * + * @param fn + * a function that initializes a builder to create the + * {@link PutAmazonsagemakerRequest} + * @see Documentation + * on elastic.co + */ + + public final CompletableFuture putAmazonsagemaker( + Function> fn) { + return putAmazonsagemaker(fn.apply(new PutAmazonsagemakerRequest.Builder()).build()); + } + // ----- Endpoint: inference.put_anthropic /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceClient.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceClient.java index 41df09f19..a470a7fa9 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceClient.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/ElasticsearchInferenceClient.java @@ -336,29 +336,35 @@ public final InferenceResponse inference(Functionsparse_embedding, text_embedding) *

  • Amazon Bedrock (completion, * text_embedding)
  • + *
  • Amazon SageMaker (chat_completion, completion, + * rerank, sparse_embedding, + * text_embedding)
  • *
  • Anthropic (completion)
  • *
  • Azure AI Studio (completion, * text_embedding)
  • *
  • Azure OpenAI (completion, text_embedding)
  • *
  • Cohere (completion, rerank, * text_embedding)
  • - *
  • DeepSeek (completion, chat_completion)
  • + *
  • DeepSeek (chat_completion, completion)
  • *
  • Elasticsearch (rerank, sparse_embedding, * text_embedding - this service is for built-in models and models * uploaded through Eland)
  • *
  • ELSER (sparse_embedding)
  • *
  • Google AI Studio (completion, * text_embedding)
  • - *
  • Google Vertex AI (rerank, text_embedding)
  • + *
  • Google Vertex AI (chat_completion, completion, + * rerank, text_embedding)
  • *
  • Hugging Face (chat_completion, completion, * rerank, text_embedding)
  • + *
  • JinaAI (rerank, text_embedding)
  • + *
  • Llama (chat_completion, completion, + * text_embedding)
  • *
  • Mistral (chat_completion, completion, * text_embedding)
  • *
  • OpenAI (chat_completion, completion, * text_embedding)
  • - *
  • VoyageAI (text_embedding, rerank)
  • + *
  • VoyageAI (rerank, text_embedding)
  • *
  • Watsonx inference integration (text_embedding)
  • - *
  • JinaAI (text_embedding, rerank)
  • * * * @see sparse_embedding, text_embedding) *
  • Amazon Bedrock (completion, * text_embedding)
  • + *
  • Amazon SageMaker (chat_completion, completion, + * rerank, sparse_embedding, + * text_embedding)
  • *
  • Anthropic (completion)
  • *
  • Azure AI Studio (completion, * text_embedding)
  • *
  • Azure OpenAI (completion, text_embedding)
  • *
  • Cohere (completion, rerank, * text_embedding)
  • - *
  • DeepSeek (completion, chat_completion)
  • + *
  • DeepSeek (chat_completion, completion)
  • *
  • Elasticsearch (rerank, sparse_embedding, * text_embedding - this service is for built-in models and models * uploaded through Eland)
  • *
  • ELSER (sparse_embedding)
  • *
  • Google AI Studio (completion, * text_embedding)
  • - *
  • Google Vertex AI (rerank, text_embedding)
  • + *
  • Google Vertex AI (chat_completion, completion, + * rerank, text_embedding)
  • *
  • Hugging Face (chat_completion, completion, * rerank, text_embedding)
  • + *
  • JinaAI (rerank, text_embedding)
  • + *
  • Llama (chat_completion, completion, + * text_embedding)
  • *
  • Mistral (chat_completion, completion, * text_embedding)
  • *
  • OpenAI (chat_completion, completion, * text_embedding)
  • - *
  • VoyageAI (text_embedding, rerank)
  • + *
  • VoyageAI (rerank, text_embedding)
  • *
  • Watsonx inference integration (text_embedding)
  • - *
  • JinaAI (text_embedding, rerank)
  • * * * @param fn @@ -530,6 +542,47 @@ public final PutAmazonbedrockResponse putAmazonbedrock( return putAmazonbedrock(fn.apply(new PutAmazonbedrockRequest.Builder()).build()); } + // ----- Endpoint: inference.put_amazonsagemaker + + /** + * Create an Amazon SageMaker inference endpoint. + *

    + * Create an inference endpoint to perform an inference task with the + * amazon_sagemaker service. + * + * @see Documentation + * on elastic.co + */ + + public PutAmazonsagemakerResponse putAmazonsagemaker(PutAmazonsagemakerRequest request) + throws IOException, ElasticsearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint) PutAmazonsagemakerRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Create an Amazon SageMaker inference endpoint. + *

    + * Create an inference endpoint to perform an inference task with the + * amazon_sagemaker service. + * + * @param fn + * a function that initializes a builder to create the + * {@link PutAmazonsagemakerRequest} + * @see Documentation + * on elastic.co + */ + + public final PutAmazonsagemakerResponse putAmazonsagemaker( + Function> fn) + throws IOException, ElasticsearchException { + return putAmazonsagemaker(fn.apply(new PutAmazonsagemakerRequest.Builder()).build()); + } + // ----- Endpoint: inference.put_anthropic /** diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/InferenceChunkingSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/InferenceChunkingSettings.java index 7f85053c3..5903bb9a5 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/InferenceChunkingSettings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/InferenceChunkingSettings.java @@ -26,11 +26,13 @@ import co.elastic.clients.json.JsonpUtils; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; import java.lang.Integer; import java.lang.String; +import java.util.List; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -70,6 +72,10 @@ public class InferenceChunkingSettings implements JsonpSerializable { @Nullable private final Integer sentenceOverlap; + private final String separatorGroup; + + private final List separators; + @Nullable private final String strategy; @@ -80,6 +86,8 @@ private InferenceChunkingSettings(Builder builder) { this.maxChunkSize = builder.maxChunkSize; this.overlap = builder.overlap; this.sentenceOverlap = builder.sentenceOverlap; + this.separatorGroup = ApiTypeHelper.requireNonNull(builder.separatorGroup, this, "separatorGroup"); + this.separators = ApiTypeHelper.unmodifiableRequired(builder.separators, this, "separators"); this.strategy = builder.strategy; } @@ -125,7 +133,53 @@ public final Integer sentenceOverlap() { } /** - * The chunking strategy: sentence or word. + * Required - This parameter is only applicable when using the + * recursive chunking strategy. + *

    + * Sets a predefined list of separators in the saved chunking settings based on + * the selected text type. Values can be markdown or + * plaintext. + *

    + * Using this parameter is an alternative to manually specifying a custom + * separators list. + *

    + * API name: {@code separator_group} + */ + public final String separatorGroup() { + return this.separatorGroup; + } + + /** + * Required - A list of strings used as possible split points when chunking text + * with the recursive strategy. + *

    + * Each string can be a plain string or a regular expression (regex) pattern. + * The system tries each separator in order to split the text, starting from the + * first item in the list. + *

    + * After splitting, it attempts to recombine smaller pieces into larger chunks + * that stay within the max_chunk_size limit, to reduce the total + * number of chunks generated. + *

    + * API name: {@code separators} + */ + public final List separators() { + return this.separators; + } + + /** + * The chunking strategy: sentence, word, + * none or recursive. + *

    + * + *

    + * Learn more about different chunking strategies in the linked documentation. *

    * API name: {@code strategy} */ @@ -159,6 +213,19 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("sentence_overlap"); generator.write(this.sentenceOverlap); + } + generator.writeKey("separator_group"); + generator.write(this.separatorGroup); + + if (ApiTypeHelper.isDefined(this.separators)) { + generator.writeKey("separators"); + generator.writeStartArray(); + for (String item0 : this.separators) { + generator.write(item0); + + } + generator.writeEnd(); + } if (this.strategy != null) { generator.writeKey("strategy"); @@ -191,6 +258,10 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Integer sentenceOverlap; + private String separatorGroup; + + private List separators; + @Nullable private String strategy; @@ -231,7 +302,78 @@ public final Builder sentenceOverlap(@Nullable Integer value) { } /** - * The chunking strategy: sentence or word. + * Required - This parameter is only applicable when using the + * recursive chunking strategy. + *

    + * Sets a predefined list of separators in the saved chunking settings based on + * the selected text type. Values can be markdown or + * plaintext. + *

    + * Using this parameter is an alternative to manually specifying a custom + * separators list. + *

    + * API name: {@code separator_group} + */ + public final Builder separatorGroup(String value) { + this.separatorGroup = value; + return this; + } + + /** + * Required - A list of strings used as possible split points when chunking text + * with the recursive strategy. + *

    + * Each string can be a plain string or a regular expression (regex) pattern. + * The system tries each separator in order to split the text, starting from the + * first item in the list. + *

    + * After splitting, it attempts to recombine smaller pieces into larger chunks + * that stay within the max_chunk_size limit, to reduce the total + * number of chunks generated. + *

    + * API name: {@code separators} + *

    + * Adds all elements of list to separators. + */ + public final Builder separators(List list) { + this.separators = _listAddAll(this.separators, list); + return this; + } + + /** + * Required - A list of strings used as possible split points when chunking text + * with the recursive strategy. + *

    + * Each string can be a plain string or a regular expression (regex) pattern. + * The system tries each separator in order to split the text, starting from the + * first item in the list. + *

    + * After splitting, it attempts to recombine smaller pieces into larger chunks + * that stay within the max_chunk_size limit, to reduce the total + * number of chunks generated. + *

    + * API name: {@code separators} + *

    + * Adds one or more values to separators. + */ + public final Builder separators(String value, String... values) { + this.separators = _listAdd(this.separators, value, values); + return this; + } + + /** + * The chunking strategy: sentence, word, + * none or recursive. + *

    + * + *

    + * Learn more about different chunking strategies in the linked documentation. *

    * API name: {@code strategy} */ @@ -272,6 +414,9 @@ protected static void setupInferenceChunkingSettingsDeserializer( op.add(Builder::maxChunkSize, JsonpDeserializer.integerDeserializer(), "max_chunk_size"); op.add(Builder::overlap, JsonpDeserializer.integerDeserializer(), "overlap"); op.add(Builder::sentenceOverlap, JsonpDeserializer.integerDeserializer(), "sentence_overlap"); + op.add(Builder::separatorGroup, JsonpDeserializer.stringDeserializer(), "separator_group"); + op.add(Builder::separators, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), + "separators"); op.add(Builder::strategy, JsonpDeserializer.stringDeserializer(), "strategy"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/InferenceEndpointInfoAmazonSageMaker.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/InferenceEndpointInfoAmazonSageMaker.java new file mode 100644 index 000000000..4c1e5d90a --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/InferenceEndpointInfoAmazonSageMaker.java @@ -0,0 +1,141 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.elasticsearch.inference; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.Objects; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: inference._types.InferenceEndpointInfoAmazonSageMaker + +/** + * + * @see API + * specification + */ + +public abstract class InferenceEndpointInfoAmazonSageMaker extends InferenceEndpoint { + private final String inferenceId; + + private final TaskTypeAmazonSageMaker taskType; + + // --------------------------------------------------------------------------------------------- + + protected InferenceEndpointInfoAmazonSageMaker(AbstractBuilder builder) { + super(builder); + + this.inferenceId = ApiTypeHelper.requireNonNull(builder.inferenceId, this, "inferenceId"); + this.taskType = ApiTypeHelper.requireNonNull(builder.taskType, this, "taskType"); + + } + + /** + * Required - The inference Id + *

    + * API name: {@code inference_id} + */ + public final String inferenceId() { + return this.inferenceId; + } + + /** + * Required - The task type + *

    + * API name: {@code task_type} + */ + public final TaskTypeAmazonSageMaker taskType() { + return this.taskType; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + generator.writeKey("inference_id"); + generator.write(this.inferenceId); + + generator.writeKey("task_type"); + this.taskType.serialize(generator, mapper); + + } + + public abstract static class AbstractBuilder> + extends + InferenceEndpoint.AbstractBuilder { + private String inferenceId; + + private TaskTypeAmazonSageMaker taskType; + + /** + * Required - The inference Id + *

    + * API name: {@code inference_id} + */ + public final BuilderT inferenceId(String value) { + this.inferenceId = value; + return self(); + } + + /** + * Required - The task type + *

    + * API name: {@code task_type} + */ + public final BuilderT taskType(TaskTypeAmazonSageMaker value) { + this.taskType = value; + return self(); + } + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupInferenceEndpointInfoAmazonSageMakerDeserializer( + ObjectDeserializer op) { + InferenceEndpoint.setupInferenceEndpointDeserializer(op); + op.add(AbstractBuilder::inferenceId, JsonpDeserializer.stringDeserializer(), "inference_id"); + op.add(AbstractBuilder::taskType, TaskTypeAmazonSageMaker._DESERIALIZER, "task_type"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutAmazonsagemakerRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutAmazonsagemakerRequest.java new file mode 100644 index 000000000..13129bb0f --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutAmazonsagemakerRequest.java @@ -0,0 +1,452 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.elasticsearch.inference; + +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.RequestBase; +import co.elastic.clients.elasticsearch._types.Time; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.JsonpSerializable; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.transport.Endpoint; +import co.elastic.clients.transport.endpoints.SimpleEndpoint; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: inference.put_amazonsagemaker.Request + +/** + * Create an Amazon SageMaker inference endpoint. + *

    + * Create an inference endpoint to perform an inference task with the + * amazon_sagemaker service. + * + * @see API + * specification + */ +@JsonpDeserializable +public class PutAmazonsagemakerRequest extends RequestBase implements JsonpSerializable { + private final String amazonsagemakerInferenceId; + + @Nullable + private final InferenceChunkingSettings chunkingSettings; + + private final AmazonSageMakerServiceType service; + + private final AmazonSageMakerServiceSettings serviceSettings; + + @Nullable + private final AmazonSageMakerTaskSettings taskSettings; + + private final TaskTypeAmazonSageMaker taskType; + + @Nullable + private final Time timeout; + + // --------------------------------------------------------------------------------------------- + + private PutAmazonsagemakerRequest(Builder builder) { + + this.amazonsagemakerInferenceId = ApiTypeHelper.requireNonNull(builder.amazonsagemakerInferenceId, this, + "amazonsagemakerInferenceId"); + this.chunkingSettings = builder.chunkingSettings; + this.service = ApiTypeHelper.requireNonNull(builder.service, this, "service"); + this.serviceSettings = ApiTypeHelper.requireNonNull(builder.serviceSettings, this, "serviceSettings"); + this.taskSettings = builder.taskSettings; + this.taskType = ApiTypeHelper.requireNonNull(builder.taskType, this, "taskType"); + this.timeout = builder.timeout; + + } + + public static PutAmazonsagemakerRequest of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The unique identifier of the inference endpoint. + *

    + * API name: {@code amazonsagemaker_inference_id} + */ + public final String amazonsagemakerInferenceId() { + return this.amazonsagemakerInferenceId; + } + + /** + * The chunking configuration object. + *

    + * API name: {@code chunking_settings} + */ + @Nullable + public final InferenceChunkingSettings chunkingSettings() { + return this.chunkingSettings; + } + + /** + * Required - The type of service supported for the specified task type. In this + * case, amazon_sagemaker. + *

    + * API name: {@code service} + */ + public final AmazonSageMakerServiceType service() { + return this.service; + } + + /** + * Required - Settings used to install the inference model. These settings are + * specific to the amazon_sagemaker service and + * service_settings.api you specified. + *

    + * API name: {@code service_settings} + */ + public final AmazonSageMakerServiceSettings serviceSettings() { + return this.serviceSettings; + } + + /** + * Settings to configure the inference task. These settings are specific to the + * task type and service_settings.api you specified. + *

    + * API name: {@code task_settings} + */ + @Nullable + public final AmazonSageMakerTaskSettings taskSettings() { + return this.taskSettings; + } + + /** + * Required - The type of the inference task that the model will perform. + *

    + * API name: {@code task_type} + */ + public final TaskTypeAmazonSageMaker taskType() { + return this.taskType; + } + + /** + * Specifies the amount of time to wait for the inference endpoint to be + * created. + *

    + * API name: {@code timeout} + */ + @Nullable + public final Time timeout() { + return this.timeout; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.chunkingSettings != null) { + generator.writeKey("chunking_settings"); + this.chunkingSettings.serialize(generator, mapper); + + } + generator.writeKey("service"); + this.service.serialize(generator, mapper); + generator.writeKey("service_settings"); + this.serviceSettings.serialize(generator, mapper); + + if (this.taskSettings != null) { + generator.writeKey("task_settings"); + this.taskSettings.serialize(generator, mapper); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link PutAmazonsagemakerRequest}. + */ + + public static class Builder extends RequestBase.AbstractBuilder + implements + ObjectBuilder { + private String amazonsagemakerInferenceId; + + @Nullable + private InferenceChunkingSettings chunkingSettings; + + private AmazonSageMakerServiceType service; + + private AmazonSageMakerServiceSettings serviceSettings; + + @Nullable + private AmazonSageMakerTaskSettings taskSettings; + + private TaskTypeAmazonSageMaker taskType; + + @Nullable + private Time timeout; + + /** + * Required - The unique identifier of the inference endpoint. + *

    + * API name: {@code amazonsagemaker_inference_id} + */ + public final Builder amazonsagemakerInferenceId(String value) { + this.amazonsagemakerInferenceId = value; + return this; + } + + /** + * The chunking configuration object. + *

    + * API name: {@code chunking_settings} + */ + public final Builder chunkingSettings(@Nullable InferenceChunkingSettings value) { + this.chunkingSettings = value; + return this; + } + + /** + * The chunking configuration object. + *

    + * API name: {@code chunking_settings} + */ + public final Builder chunkingSettings( + Function> fn) { + return this.chunkingSettings(fn.apply(new InferenceChunkingSettings.Builder()).build()); + } + + /** + * Required - The type of service supported for the specified task type. In this + * case, amazon_sagemaker. + *

    + * API name: {@code service} + */ + public final Builder service(AmazonSageMakerServiceType value) { + this.service = value; + return this; + } + + /** + * Required - Settings used to install the inference model. These settings are + * specific to the amazon_sagemaker service and + * service_settings.api you specified. + *

    + * API name: {@code service_settings} + */ + public final Builder serviceSettings(AmazonSageMakerServiceSettings value) { + this.serviceSettings = value; + return this; + } + + /** + * Required - Settings used to install the inference model. These settings are + * specific to the amazon_sagemaker service and + * service_settings.api you specified. + *

    + * API name: {@code service_settings} + */ + public final Builder serviceSettings( + Function> fn) { + return this.serviceSettings(fn.apply(new AmazonSageMakerServiceSettings.Builder()).build()); + } + + /** + * Settings to configure the inference task. These settings are specific to the + * task type and service_settings.api you specified. + *

    + * API name: {@code task_settings} + */ + public final Builder taskSettings(@Nullable AmazonSageMakerTaskSettings value) { + this.taskSettings = value; + return this; + } + + /** + * Settings to configure the inference task. These settings are specific to the + * task type and service_settings.api you specified. + *

    + * API name: {@code task_settings} + */ + public final Builder taskSettings( + Function> fn) { + return this.taskSettings(fn.apply(new AmazonSageMakerTaskSettings.Builder()).build()); + } + + /** + * Required - The type of the inference task that the model will perform. + *

    + * API name: {@code task_type} + */ + public final Builder taskType(TaskTypeAmazonSageMaker value) { + this.taskType = value; + return this; + } + + /** + * Specifies the amount of time to wait for the inference endpoint to be + * created. + *

    + * API name: {@code timeout} + */ + public final Builder timeout(@Nullable Time value) { + this.timeout = value; + return this; + } + + /** + * Specifies the amount of time to wait for the inference endpoint to be + * created. + *

    + * API name: {@code timeout} + */ + public final Builder timeout(Function> fn) { + return this.timeout(fn.apply(new Time.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link PutAmazonsagemakerRequest}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public PutAmazonsagemakerRequest build() { + _checkSingleUse(); + + return new PutAmazonsagemakerRequest(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link PutAmazonsagemakerRequest} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, PutAmazonsagemakerRequest::setupPutAmazonsagemakerRequestDeserializer); + + protected static void setupPutAmazonsagemakerRequestDeserializer( + ObjectDeserializer op) { + + op.add(Builder::chunkingSettings, InferenceChunkingSettings._DESERIALIZER, "chunking_settings"); + op.add(Builder::service, AmazonSageMakerServiceType._DESERIALIZER, "service"); + op.add(Builder::serviceSettings, AmazonSageMakerServiceSettings._DESERIALIZER, "service_settings"); + op.add(Builder::taskSettings, AmazonSageMakerTaskSettings._DESERIALIZER, "task_settings"); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code inference.put_amazonsagemaker}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + "es/inference.put_amazonsagemaker", + + // Request method + request -> { + return "PUT"; + + }, + + // Request path + request -> { + final int _amazonsagemakerInferenceId = 1 << 0; + final int _taskType = 1 << 1; + + int propsSet = 0; + + propsSet |= _amazonsagemakerInferenceId; + propsSet |= _taskType; + + if (propsSet == (_taskType | _amazonsagemakerInferenceId)) { + StringBuilder buf = new StringBuilder(); + buf.append("/_inference"); + buf.append("/"); + SimpleEndpoint.pathEncode(request.taskType.jsonValue(), buf); + buf.append("/"); + SimpleEndpoint.pathEncode(request.amazonsagemakerInferenceId, buf); + return buf.toString(); + } + throw SimpleEndpoint.noPathTemplateFound("path"); + + }, + + // Path parameters + request -> { + Map params = new HashMap<>(); + final int _amazonsagemakerInferenceId = 1 << 0; + final int _taskType = 1 << 1; + + int propsSet = 0; + + propsSet |= _amazonsagemakerInferenceId; + propsSet |= _taskType; + + if (propsSet == (_taskType | _amazonsagemakerInferenceId)) { + params.put("taskType", request.taskType.jsonValue()); + params.put("amazonsagemakerInferenceId", request.amazonsagemakerInferenceId); + } + return params; + }, + + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.timeout != null) { + params.put("timeout", request.timeout._toJsonString()); + } + return params; + + }, SimpleEndpoint.emptyMap(), true, PutAmazonsagemakerResponse._DESERIALIZER); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutAmazonsagemakerResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutAmazonsagemakerResponse.java new file mode 100644 index 000000000..b9a83c05d --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutAmazonsagemakerResponse.java @@ -0,0 +1,108 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.elasticsearch.inference; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: inference.put_amazonsagemaker.Response + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class PutAmazonsagemakerResponse extends InferenceEndpointInfoAmazonSageMaker { + // --------------------------------------------------------------------------------------------- + + private PutAmazonsagemakerResponse(Builder builder) { + super(builder); + + } + + public static PutAmazonsagemakerResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link PutAmazonsagemakerResponse}. + */ + + public static class Builder extends InferenceEndpointInfoAmazonSageMaker.AbstractBuilder + implements + ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link PutAmazonsagemakerResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public PutAmazonsagemakerResponse build() { + _checkSingleUse(); + + return new PutAmazonsagemakerResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link PutAmazonsagemakerResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, PutAmazonsagemakerResponse::setupPutAmazonsagemakerResponseDeserializer); + + protected static void setupPutAmazonsagemakerResponseDeserializer( + ObjectDeserializer op) { + InferenceEndpointInfoAmazonSageMaker.setupInferenceEndpointInfoAmazonSageMakerDeserializer(op); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutRequest.java index 3a73a84f3..c1264f680 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutRequest.java @@ -77,29 +77,35 @@ * sparse_embedding, text_embedding) *

  • Amazon Bedrock (completion, * text_embedding)
  • + *
  • Amazon SageMaker (chat_completion, completion, + * rerank, sparse_embedding, + * text_embedding)
  • *
  • Anthropic (completion)
  • *
  • Azure AI Studio (completion, * text_embedding)
  • *
  • Azure OpenAI (completion, text_embedding)
  • *
  • Cohere (completion, rerank, * text_embedding)
  • - *
  • DeepSeek (completion, chat_completion)
  • + *
  • DeepSeek (chat_completion, completion)
  • *
  • Elasticsearch (rerank, sparse_embedding, * text_embedding - this service is for built-in models and models * uploaded through Eland)
  • *
  • ELSER (sparse_embedding)
  • *
  • Google AI Studio (completion, * text_embedding)
  • - *
  • Google Vertex AI (rerank, text_embedding)
  • + *
  • Google Vertex AI (chat_completion, completion, + * rerank, text_embedding)
  • *
  • Hugging Face (chat_completion, completion, * rerank, text_embedding)
  • + *
  • JinaAI (rerank, text_embedding)
  • + *
  • Llama (chat_completion, completion, + * text_embedding)
  • *
  • Mistral (chat_completion, completion, * text_embedding)
  • *
  • OpenAI (chat_completion, completion, * text_embedding)
  • - *
  • VoyageAI (text_embedding, rerank)
  • + *
  • VoyageAI (rerank, text_embedding)
  • *
  • Watsonx inference integration (text_embedding)
  • - *
  • JinaAI (text_embedding, rerank)
  • * * * @see API diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/TaskTypeAmazonSageMaker.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/TaskTypeAmazonSageMaker.java new file mode 100644 index 000000000..b372a82d1 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/inference/TaskTypeAmazonSageMaker.java @@ -0,0 +1,73 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.elasticsearch.inference; + +import co.elastic.clients.json.JsonEnum; +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public enum TaskTypeAmazonSageMaker implements JsonEnum { + TextEmbedding("text_embedding"), + + Completion("completion"), + + ChatCompletion("chat_completion"), + + SparseEmbedding("sparse_embedding"), + + Rerank("rerank"), + + ; + + private final String jsonValue; + + TaskTypeAmazonSageMaker(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + TaskTypeAmazonSageMaker.values()); +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/QueryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/QueryRequest.java index 1df25b73d..5e2c616ec 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/QueryRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/QueryRequest.java @@ -43,6 +43,7 @@ import java.lang.String; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; @@ -109,7 +110,7 @@ public class QueryRequest extends RequestBase implements JsonpSerializable { @Nullable private final Time pageTimeout; - private final Map params; + private final List params; @Nullable private final String query; @@ -299,7 +300,7 @@ public final Time pageTimeout() { *

    * API name: {@code params} */ - public final Map params() { + public final List params() { return this.params; } @@ -426,10 +427,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } if (ApiTypeHelper.isDefined(this.params)) { generator.writeKey("params"); - generator.writeStartObject(); - for (Map.Entry item0 : this.params.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); + generator.writeStartArray(); + for (JsonData item0 : this.params) { + item0.serialize(generator, mapper); } generator.writeEnd(); @@ -513,7 +513,7 @@ public static class Builder extends RequestBase.AbstractBuilder impleme private Time pageTimeout; @Nullable - private Map params; + private List params; @Nullable private String query; @@ -715,10 +715,10 @@ public final Builder pageTimeout(Function> fn) *

    * API name: {@code params} *

    - * Adds all entries of map to params. + * Adds all elements of list to params. */ - public final Builder params(Map map) { - this.params = _mapPutAll(this.params, map); + public final Builder params(List list) { + this.params = _listAddAll(this.params, list); return this; } @@ -727,10 +727,10 @@ public final Builder params(Map map) { *

    * API name: {@code params} *

    - * Adds an entry to params. + * Adds one or more values to params. */ - public final Builder params(String key, JsonData value) { - this.params = _mapPut(this.params, key, value); + public final Builder params(JsonData value, JsonData... values) { + this.params = _listAdd(this.params, value, values); return this; } @@ -881,7 +881,7 @@ protected static void setupQueryRequestDeserializer(ObjectDeserializer> list) { *

    * Adds one or more values to inputs. */ + @SafeVarargs public final Builder inputs(NamedValue value, NamedValue... values) { this.inputs = _listAdd(this.inputs, value, values); return this; diff --git a/java-client/src/main/java/co/elastic/clients/transport/rest5_client/Rest5ClientOptions.java b/java-client/src/main/java/co/elastic/clients/transport/rest5_client/Rest5ClientOptions.java index 0e553088a..6135a6738 100644 --- a/java-client/src/main/java/co/elastic/clients/transport/rest5_client/Rest5ClientOptions.java +++ b/java-client/src/main/java/co/elastic/clients/transport/rest5_client/Rest5ClientOptions.java @@ -209,7 +209,7 @@ public Rest5ClientOptions build() { } static Rest5ClientOptions initialOptions() { - return new Rest5ClientOptions(RequestOptions.DEFAULT, false); + return new Rest5ClientOptions(SafeResponseConsumer.DEFAULT_REQUEST_OPTIONS, false); } private static RequestOptions.Builder addBuiltinHeaders(RequestOptions.Builder builder) { diff --git a/java-client/src/main/java/co/elastic/clients/transport/rest5_client/SafeResponseConsumer.java b/java-client/src/main/java/co/elastic/clients/transport/rest5_client/SafeResponseConsumer.java new file mode 100644 index 000000000..69fccfdfe --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/transport/rest5_client/SafeResponseConsumer.java @@ -0,0 +1,137 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.transport.rest5_client; + +import co.elastic.clients.transport.rest5_client.low_level.HttpAsyncResponseConsumerFactory; +import co.elastic.clients.transport.rest5_client.low_level.RequestOptions; +import org.apache.hc.core5.concurrent.FutureCallback; +import org.apache.hc.core5.http.EntityDetails; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.http.nio.AsyncResponseConsumer; +import org.apache.hc.core5.http.nio.CapacityChannel; +import org.apache.hc.core5.http.protocol.HttpContext; + +import java.nio.ByteBuffer; +import java.util.List; + +/** + * A response consumer that will propagate Errors as RuntimeExceptions to avoid crashing the IOReactor. + */ +public class SafeResponseConsumer implements AsyncResponseConsumer { + + private final AsyncResponseConsumer delegate; + + public SafeResponseConsumer(AsyncResponseConsumer delegate) { + this.delegate = delegate; + } + + /** + * A consumer factory that safely wraps the one provided by {@code RequestOptions.DEFAULT}. + */ + public static final HttpAsyncResponseConsumerFactory DEFAULT_FACTORY = () -> new SafeResponseConsumer<>( + RequestOptions.DEFAULT.getHttpAsyncResponseConsumerFactory().createHttpAsyncResponseConsumer() + ); + + /** + * Same as {@code RequestOptions.DEFAULT} with a safe consumer factory + */ + public static final RequestOptions DEFAULT_REQUEST_OPTIONS = RequestOptions.DEFAULT + .toBuilder() + .setHttpAsyncResponseConsumerFactory(DEFAULT_FACTORY) + .build(); + + @SuppressWarnings("unchecked") + private static void throwUnchecked(Throwable thr) throws T { + throw (T) thr; + } + + @Override + public void consumeResponse(HttpResponse response, EntityDetails entityDetails, HttpContext context, + FutureCallback resultCallback) { + try { + delegate.consumeResponse(response, entityDetails, context, resultCallback); + } catch (Exception e) { + throwUnchecked(e); + } catch (Throwable e) { + throw new RuntimeException("Error consuming response", e); + } + } + + @Override + public void informationResponse(HttpResponse response, HttpContext context) { + try { + delegate.informationResponse(response, context); + } catch (Exception e) { + throwUnchecked(e); + } catch (Throwable e) { + throw new RuntimeException("Error information response", e); + } + } + + @Override + public void failed(Exception cause) { + try { + delegate.failed(cause); + } catch (Exception e) { + throwUnchecked(e); + } catch (Throwable e) { + throw new RuntimeException("Error handling failure", e); + } + } + + @Override + public void updateCapacity(CapacityChannel capacityChannel) { + try { + delegate.updateCapacity(capacityChannel); + } catch (Exception e) { + throwUnchecked(e); + } catch (Throwable e) { + throw new RuntimeException("Error updating capacity", e); + } + } + + @Override + public void consume(ByteBuffer src) { + try { + delegate.consume(src); + } catch (Exception e) { + throwUnchecked(e); + } catch (Throwable e) { + throw new RuntimeException("Error consuming data", e); + } + } + + @Override + public void streamEnd(List trailers) { + try { + delegate.streamEnd(trailers); + } catch (Exception e) { + throwUnchecked(e); + } catch (Throwable e) { + throw new RuntimeException("Error triggering stream end", e); + } + } + + @Override + public void releaseResources() { + delegate.releaseResources(); + } +} diff --git a/java-client/src/test/java/co/elastic/clients/transport/rest5_client/low_level/SafeResponseConsumerTest.java b/java-client/src/test/java/co/elastic/clients/transport/rest5_client/low_level/SafeResponseConsumerTest.java new file mode 100644 index 000000000..d22f1fbc9 --- /dev/null +++ b/java-client/src/test/java/co/elastic/clients/transport/rest5_client/low_level/SafeResponseConsumerTest.java @@ -0,0 +1,158 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 + * + * http://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 co.elastic.clients.transport.rest5_client.low_level; + +import co.elastic.clients.transport.rest5_client.SafeResponseConsumer; +import com.sun.net.httpserver.HttpServer; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.http.io.entity.ByteArrayEntity; +import org.apache.hc.core5.http.message.BasicClassicHttpResponse; +import org.apache.hc.core5.http.protocol.HttpContext; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; + +public class SafeResponseConsumerTest { + + static HttpServer Server; + static HttpHost ESHost; + + // A consumer factory that throws an Error, to simulate the effect of an OOME + static HttpAsyncResponseConsumerFactory FailingConsumerFactory = + () -> new BasicAsyncResponseConsumer(new BufferedByteConsumer(100 * 1024 * 1024)) { + @Override + public void informationResponse(HttpResponse response, HttpContext context) { + super.informationResponse(response, context); + } + + @Override + protected BasicClassicHttpResponse buildResult(HttpResponse response, ByteArrayEntity entity, + ContentType contentType) { + super.buildResult(response, entity, contentType); + throw new Error("Error in buildResult"); + } + }; + + @BeforeAll + public static void setup() throws Exception { + Server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + Server.start(); + + Server.createContext("/", exchange -> { + String path = exchange.getRequestURI().getPath(); + exchange.getResponseHeaders().set("Content-Type", "application/json"); + exchange.getResponseHeaders().set("X-Elastic-Product", "Elasticsearch"); + + if (path.equals("/")) { + byte[] bytes = Info.getBytes(StandardCharsets.UTF_8); + exchange.sendResponseHeaders(200, bytes.length); + exchange.getResponseBody().write(bytes); + exchange.close(); + return; + } + + exchange.sendResponseHeaders(404, -1); + exchange.close(); + }); + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + try { + Server.stop(1); + } catch (Exception e) { + // Ignore + } + })); + + ESHost = new HttpHost(Server.getAddress().getAddress(), Server.getAddress().getPort()); + } + + @AfterAll + public static void tearDown() { + Server.stop(0); + } + + // testReactorDeath cannot be tested, as the io reactor thread gets stuck and the test never completes + + @Test + public void testReactorSurvival() throws Exception { + + // Request options that will simulate an OOME and wrapped in the safe consumer that will + // avoid the reactor's death + RequestOptions.Builder protectedFailingOptionsBuilder = RequestOptions.DEFAULT.toBuilder(); + protectedFailingOptionsBuilder.setHttpAsyncResponseConsumerFactory(() -> + new SafeResponseConsumer<>(FailingConsumerFactory.createHttpAsyncResponseConsumer()) + ); + RequestOptions protectedFailingOptions = protectedFailingOptionsBuilder.build(); + + Rest5Client restClient = Rest5Client.builder(ESHost).build(); + + // First request, to warm things up. + // An "indice exists" request, that has no response body + Request existsReq = new Request("HEAD", "/index-name"); + restClient.performRequest(existsReq); + + try { + Request infoReq = new Request("GET", "/"); + infoReq.setOptions(protectedFailingOptions); + + restClient.performRequest(infoReq); + Assertions.fail("First request should not succeed"); + } catch (Exception t) { + System.err.println("Request 1 error"); + } + { + // 2nd request with no specific options + Request infoReq = new Request("GET", "/"); + + Response resp = restClient.performRequest(infoReq); + Assertions.assertEquals(200, resp.getStatusCode()); + } + { + // final request to make sure that the reactor isn't closed + restClient.performRequest(existsReq); + } + restClient.close(); + } + + private static final String Info = "{\n" + + " \"cluster_name\": \"foo\",\n" + + " \"cluster_uuid\": \"bar\",\n" + + " \"version\": {\n" + + " \"build_date\": \"2022-01-28T08:36:04.875279988Z\",\n" + + " \"minimum_wire_compatibility_version\": \"6.8.0\",\n" + + " \"build_hash\": \"bee86328705acaa9a6daede7140defd4d9ec56bd\",\n" + + " \"number\": \"7.17.0\",\n" + + " \"lucene_version\": \"8.11.1\",\n" + + " \"minimum_index_compatibility_version\": \"6.0.0-beta1\",\n" + + " \"build_flavor\": \"default\",\n" + + " \"build_snapshot\": false,\n" + + " \"build_type\": \"docker\"\n" + + " },\n" + + " \"name\": \"instance-0000000000\",\n" + + " \"tagline\": \"You Know, for Search\"\n" + + "}"; +}