Skip to content

[Backport 9.0] Fix IndexName inference (and regenerate client) #8521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Elastic.Clients.Elasticsearch.Cluster;

internal sealed partial class ClusterStatsResponseConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.Cluster.ClusterStatsResponse>
{
private static readonly System.Text.Json.JsonEncodedText PropCcs = System.Text.Json.JsonEncodedText.Encode("ccs");
private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name");
private static readonly System.Text.Json.JsonEncodedText PropClusterUuid = System.Text.Json.JsonEncodedText.Encode("cluster_uuid");
private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices");
Expand All @@ -36,6 +37,7 @@ internal sealed partial class ClusterStatsResponseConverter : System.Text.Json.S
public override Elastic.Clients.Elasticsearch.Cluster.ClusterStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
{
reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject);
LocalJsonValue<Elastic.Clients.Elasticsearch.Cluster.CCSStats> propCcs = default;
LocalJsonValue<string> propClusterName = default;
LocalJsonValue<string> propClusterUuid = default;
LocalJsonValue<Elastic.Clients.Elasticsearch.Cluster.ClusterIndices> propIndices = default;
Expand All @@ -45,6 +47,11 @@ public override Elastic.Clients.Elasticsearch.Cluster.ClusterStatsResponse Read(
LocalJsonValue<long> propTimestamp = default;
while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName)
{
if (propCcs.TryReadProperty(ref reader, options, PropCcs, null))
{
continue;
}

if (propClusterName.TryReadProperty(ref reader, options, PropClusterName, null))
{
continue;
Expand Down Expand Up @@ -92,6 +99,7 @@ public override Elastic.Clients.Elasticsearch.Cluster.ClusterStatsResponse Read(
reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject);
return new Elastic.Clients.Elasticsearch.Cluster.ClusterStatsResponse(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance)
{
Ccs = propCcs.Value,
ClusterName = propClusterName.Value,
ClusterUuid = propClusterUuid.Value,
Indices = propIndices.Value,
Expand All @@ -105,6 +113,7 @@ public override Elastic.Clients.Elasticsearch.Cluster.ClusterStatsResponse Read(
public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Cluster.ClusterStatsResponse value, System.Text.Json.JsonSerializerOptions options)
{
writer.WriteStartObject();
writer.WriteProperty(options, PropCcs, value.Ccs, null, null);
writer.WriteProperty(options, PropClusterName, value.ClusterName, null, null);
writer.WriteProperty(options, PropClusterUuid, value.ClusterUuid, null, null);
writer.WriteProperty(options, PropIndices, value.Indices, null, null);
Expand All @@ -130,6 +139,17 @@ internal ClusterStatsResponse(Elastic.Clients.Elasticsearch.Serialization.JsonCo
_ = sentinel;
}

/// <summary>
/// <para>
/// Cross-cluster stats
/// </para>
/// </summary>
public
#if NET7_0_OR_GREATER
required
#endif
Elastic.Clients.Elasticsearch.Cluster.CCSStats Ccs { get; set; }

/// <summary>
/// <para>
/// Name of the cluster, based on the cluster name setting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ public CreateRequest(TDocument document, Elastic.Clients.Elasticsearch.IndexName
}

[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public CreateRequest(TDocument document, Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("index", typeof(TDocument)).Required("id", id))
public CreateRequest(TDocument document, Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("index", (Elastic.Clients.Elasticsearch.IndexName)typeof(TDocument)).Required("id", id))
{
Document = document;
}

[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public CreateRequest(TDocument document) : base(r => r.Required("index", typeof(TDocument)).Required("id", Elastic.Clients.Elasticsearch.Id.From(document)))
public CreateRequest(TDocument document) : base(r => r.Required("index", (Elastic.Clients.Elasticsearch.IndexName)typeof(TDocument)).Required("id", Elastic.Clients.Elasticsearch.Id.From(document)))
{
Document = document;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,45 @@ internal CreateIndexRequest(Elastic.Clients.Elasticsearch.Serialization.JsonCons
/// <summary>
/// <para>
/// Name of the index you wish to create.
/// Index names must meet the following criteria:
/// </para>
/// <list type="bullet">
/// <item>
/// <para>
/// Lowercase only
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot include <c>\</c>, <c>/</c>, <c>*</c>, <c>?</c>, <c>"</c>, <c>&lt;</c>, <c>></c>, <c>|</c>, <c> </c> (space character), <c>,</c>, or <c>#</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Indices prior to 7.0 could contain a colon (<c>:</c>), but that has been deprecated and will not be supported in later versions
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot start with <c>-</c>, <c>_</c>, or <c>+</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot be <c>.</c> or <c>..</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot be longer than 255 bytes (note thtat it is bytes, so multi-byte characters will reach the limit faster)
/// </para>
/// </item>
/// <item>
/// <para>
/// Names starting with <c>.</c> are deprecated, except for hidden indices and internal indices managed by plugins
/// </para>
/// </item>
/// </list>
/// </summary>
public
#if NET7_0_OR_GREATER
Expand Down Expand Up @@ -314,7 +352,45 @@ public CreateIndexRequestDescriptor()
/// <summary>
/// <para>
/// Name of the index you wish to create.
/// Index names must meet the following criteria:
/// </para>
/// <list type="bullet">
/// <item>
/// <para>
/// Lowercase only
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot include <c>\</c>, <c>/</c>, <c>*</c>, <c>?</c>, <c>"</c>, <c>&lt;</c>, <c>></c>, <c>|</c>, <c> </c> (space character), <c>,</c>, or <c>#</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Indices prior to 7.0 could contain a colon (<c>:</c>), but that has been deprecated and will not be supported in later versions
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot start with <c>-</c>, <c>_</c>, or <c>+</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot be <c>.</c> or <c>..</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot be longer than 255 bytes (note thtat it is bytes, so multi-byte characters will reach the limit faster)
/// </para>
/// </item>
/// <item>
/// <para>
/// Names starting with <c>.</c> are deprecated, except for hidden indices and internal indices managed by plugins
/// </para>
/// </item>
/// </list>
/// </summary>
public Elastic.Clients.Elasticsearch.IndexManagement.CreateIndexRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName value)
{
Expand Down Expand Up @@ -731,7 +807,45 @@ public CreateIndexRequestDescriptor()
/// <summary>
/// <para>
/// Name of the index you wish to create.
/// Index names must meet the following criteria:
/// </para>
/// <list type="bullet">
/// <item>
/// <para>
/// Lowercase only
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot include <c>\</c>, <c>/</c>, <c>*</c>, <c>?</c>, <c>"</c>, <c>&lt;</c>, <c>></c>, <c>|</c>, <c> </c> (space character), <c>,</c>, or <c>#</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Indices prior to 7.0 could contain a colon (<c>:</c>), but that has been deprecated and will not be supported in later versions
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot start with <c>-</c>, <c>_</c>, or <c>+</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot be <c>.</c> or <c>..</c>
/// </para>
/// </item>
/// <item>
/// <para>
/// Cannot be longer than 255 bytes (note thtat it is bytes, so multi-byte characters will reach the limit faster)
/// </para>
/// </item>
/// <item>
/// <para>
/// Names starting with <c>.</c> are deprecated, except for hidden indices and internal indices managed by plugins
/// </para>
/// </item>
/// </list>
/// </summary>
public Elastic.Clients.Elasticsearch.IndexManagement.CreateIndexRequestDescriptor<TDocument> Index(Elastic.Clients.Elasticsearch.IndexName value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ public IndexRequest(TDocument document, Elastic.Clients.Elasticsearch.IndexName
}

[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public IndexRequest(TDocument document, Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Required("index", typeof(TDocument)).Optional("id", id))
public IndexRequest(TDocument document, Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Required("index", (Elastic.Clients.Elasticsearch.IndexName)typeof(TDocument)).Optional("id", id))
{
Document = document;
}

[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public IndexRequest(TDocument document) : base(r => r.Required("index", typeof(TDocument)).Optional("id", Elastic.Clients.Elasticsearch.Id.From(document)))
public IndexRequest(TDocument document) : base(r => r.Required("index", (Elastic.Clients.Elasticsearch.IndexName)typeof(TDocument)).Optional("id", Elastic.Clients.Elasticsearch.Id.From(document)))
{
Document = document;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
/// <para>
/// Perform chat completion inference
/// </para>
/// <para>
/// The chat completion inference API enables real-time responses for chat completion tasks by delivering answers incrementally, reducing response times during computation.
/// It only works with the <c>chat_completion</c> task type for <c>openai</c> and <c>elastic</c> inference services.
/// </para>
/// <para>
/// IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Azure, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face.
/// For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models. However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs.
/// </para>
/// <para>
/// NOTE: The <c>chat_completion</c> task type is only available within the _stream API and only supports streaming.
/// The Chat completion inference API and the Stream inference API differ in their response structure and capabilities.
/// The Chat completion inference API provides more comprehensive customization options through more fields and function calling support.
/// If you use the <c>openai</c> service or the <c>elastic</c> service, use the Chat completion inference API.
/// </para>
/// </summary>
[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Inference.ChatCompletionUnifiedRequestConverter))]
public sealed partial class ChatCompletionUnifiedRequest : Elastic.Clients.Elasticsearch.Requests.PlainRequest<Elastic.Clients.Elasticsearch.Inference.ChatCompletionUnifiedRequestParameters>
Expand Down Expand Up @@ -112,6 +126,20 @@ internal ChatCompletionUnifiedRequest(Elastic.Clients.Elasticsearch.Serializatio
/// <para>
/// Perform chat completion inference
/// </para>
/// <para>
/// The chat completion inference API enables real-time responses for chat completion tasks by delivering answers incrementally, reducing response times during computation.
/// It only works with the <c>chat_completion</c> task type for <c>openai</c> and <c>elastic</c> inference services.
/// </para>
/// <para>
/// IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Azure, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face.
/// For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models. However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs.
/// </para>
/// <para>
/// NOTE: The <c>chat_completion</c> task type is only available within the _stream API and only supports streaming.
/// The Chat completion inference API and the Stream inference API differ in their response structure and capabilities.
/// The Chat completion inference API provides more comprehensive customization options through more fields and function calling support.
/// If you use the <c>openai</c> service or the <c>elastic</c> service, use the Chat completion inference API.
/// </para>
/// </summary>
public readonly partial struct ChatCompletionUnifiedRequestDescriptor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
/// <para>
/// Create an inference endpoint to perform an inference task with the <c>alibabacloud-ai-search</c> service.
/// </para>
/// <para>
/// When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
/// After creating the endpoint, wait for the model deployment to complete before using it.
/// To verify the deployment status, use the get trained model statistics API.
/// Look for <c>"state": "fully_allocated"</c> in the response and ensure that the <c>"allocation_count"</c> matches the <c>"target_allocation_count"</c>.
/// Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.
/// </para>
/// </summary>
[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Inference.PutAlibabacloudRequestConverter))]
public sealed partial class PutAlibabacloudRequest : Elastic.Clients.Elasticsearch.Requests.PlainRequest<Elastic.Clients.Elasticsearch.Inference.PutAlibabacloudRequestParameters>
Expand Down Expand Up @@ -203,13 +196,6 @@ internal PutAlibabacloudRequest(Elastic.Clients.Elasticsearch.Serialization.Json
/// <para>
/// Create an inference endpoint to perform an inference task with the <c>alibabacloud-ai-search</c> service.
/// </para>
/// <para>
/// When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
/// After creating the endpoint, wait for the model deployment to complete before using it.
/// To verify the deployment status, use the get trained model statistics API.
/// Look for <c>"state": "fully_allocated"</c> in the response and ensure that the <c>"allocation_count"</c> matches the <c>"target_allocation_count"</c>.
/// Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.
/// </para>
/// </summary>
public readonly partial struct PutAlibabacloudRequestDescriptor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
/// info
/// You need to provide the access and secret keys only once, during the inference model creation. The get inference API does not retrieve your access or secret keys. After creating the inference model, you cannot change the associated key pairs. If you want to use a different access and secret key pair, delete the inference model and recreate it with the same name and the updated keys.
/// </para>
/// <para>
/// When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
/// After creating the endpoint, wait for the model deployment to complete before using it.
/// To verify the deployment status, use the get trained model statistics API.
/// Look for <c>"state": "fully_allocated"</c> in the response and ensure that the <c>"allocation_count"</c> matches the <c>"target_allocation_count"</c>.
/// Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.
/// </para>
/// </summary>
[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Inference.PutAmazonbedrockRequestConverter))]
public sealed partial class PutAmazonbedrockRequest : Elastic.Clients.Elasticsearch.Requests.PlainRequest<Elastic.Clients.Elasticsearch.Inference.PutAmazonbedrockRequestParameters>
Expand Down Expand Up @@ -211,13 +204,6 @@ internal PutAmazonbedrockRequest(Elastic.Clients.Elasticsearch.Serialization.Jso
/// info
/// You need to provide the access and secret keys only once, during the inference model creation. The get inference API does not retrieve your access or secret keys. After creating the inference model, you cannot change the associated key pairs. If you want to use a different access and secret key pair, delete the inference model and recreate it with the same name and the updated keys.
/// </para>
/// <para>
/// When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
/// After creating the endpoint, wait for the model deployment to complete before using it.
/// To verify the deployment status, use the get trained model statistics API.
/// Look for <c>"state": "fully_allocated"</c> in the response and ensure that the <c>"allocation_count"</c> matches the <c>"target_allocation_count"</c>.
/// Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.
/// </para>
/// </summary>
public readonly partial struct PutAmazonbedrockRequestDescriptor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
/// <para>
/// Create an inference endpoint to perform an inference task with the <c>anthropic</c> service.
/// </para>
/// <para>
/// When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
/// After creating the endpoint, wait for the model deployment to complete before using it.
/// To verify the deployment status, use the get trained model statistics API.
/// Look for <c>"state": "fully_allocated"</c> in the response and ensure that the <c>"allocation_count"</c> matches the <c>"target_allocation_count"</c>.
/// Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.
/// </para>
/// </summary>
[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Inference.PutAnthropicRequestConverter))]
public sealed partial class PutAnthropicRequest : Elastic.Clients.Elasticsearch.Requests.PlainRequest<Elastic.Clients.Elasticsearch.Inference.PutAnthropicRequestParameters>
Expand Down Expand Up @@ -204,13 +197,6 @@ internal PutAnthropicRequest(Elastic.Clients.Elasticsearch.Serialization.JsonCon
/// <para>
/// Create an inference endpoint to perform an inference task with the <c>anthropic</c> service.
/// </para>
/// <para>
/// When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
/// After creating the endpoint, wait for the model deployment to complete before using it.
/// To verify the deployment status, use the get trained model statistics API.
/// Look for <c>"state": "fully_allocated"</c> in the response and ensure that the <c>"allocation_count"</c> matches the <c>"target_allocation_count"</c>.
/// Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.
/// </para>
/// </summary>
public readonly partial struct PutAnthropicRequestDescriptor
{
Expand Down
Loading