Skip to content
Closed
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 @@ -31,6 +31,7 @@ public sealed partial class TranslateResponseConverter : System.Text.Json.Serial
private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size");
private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort");
private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source");
private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits");

public override Elastic.Clients.Elasticsearch.Sql.TranslateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
{
Expand All @@ -41,6 +42,7 @@ public override Elastic.Clients.Elasticsearch.Sql.TranslateResponse Read(ref Sys
LocalJsonValue<long?> propSize = default;
LocalJsonValue<System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.SortOptions>?> propSort = default;
LocalJsonValue<Elastic.Clients.Elasticsearch.Core.Search.SourceConfig?> propSource = default;
LocalJsonValue<Elastic.Clients.Elasticsearch.Core.Search.TrackHits?> propTrackTotalHits = default;
while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName)
{
if (propAggregations.TryReadProperty(ref reader, options, PropAggregations, static System.Collections.Generic.IReadOnlyDictionary<string, Elastic.Clients.Elasticsearch.Aggregations.Aggregation>? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadDictionaryValue<string, Elastic.Clients.Elasticsearch.Aggregations.Aggregation>(o, null, null)))
Expand Down Expand Up @@ -73,6 +75,11 @@ public override Elastic.Clients.Elasticsearch.Sql.TranslateResponse Read(ref Sys
continue;
}

if (propTrackTotalHits.TryReadProperty(ref reader, options, PropTrackTotalHits, null))
{
continue;
}

if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip)
{
reader.SafeSkip();
Expand All @@ -90,7 +97,8 @@ public override Elastic.Clients.Elasticsearch.Sql.TranslateResponse Read(ref Sys
Query = propQuery.Value,
Size = propSize.Value,
Sort = propSort.Value,
Source = propSource.Value
Source = propSource.Value,
TrackTotalHits = propTrackTotalHits.Value
};
}

Expand All @@ -103,6 +111,7 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
writer.WriteProperty(options, PropSize, value.Size, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, long? v) => w.WriteNullableValue<long>(o, v));
writer.WriteProperty(options, PropSort, value.Sort, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.SortOptions>? v) => w.WriteSingleOrManyCollectionValue<Elastic.Clients.Elasticsearch.SortOptions>(o, v, null));
writer.WriteProperty(options, PropSource, value.Source, null, null);
writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits, null, null);
writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ internal TranslateResponse(Elastic.Clients.Elasticsearch.Serialization.JsonConst
public long? Size { get; set; }
public System.Collections.Generic.ICollection<Elastic.Clients.Elasticsearch.SortOptions>? Sort { get; set; }
public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; }
public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Elastic.Clients.Elasticsearch.Mapping.Json;
public sealed partial class SemanticTextPropertyConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty>
{
private static readonly System.Text.Json.JsonEncodedText PropChunkingSettings = System.Text.Json.JsonEncodedText.Encode("chunking_settings");
private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields");
private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options");
private static readonly System.Text.Json.JsonEncodedText PropInferenceId = System.Text.Json.JsonEncodedText.Encode("inference_id");
private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta");
Expand All @@ -36,6 +37,7 @@ public override Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty Read(
{
reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject);
LocalJsonValue<Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings?> propChunkingSettings = default;
LocalJsonValue<Elastic.Clients.Elasticsearch.Mapping.Properties?> propFields = default;
LocalJsonValue<Elastic.Clients.Elasticsearch.Mapping.SemanticTextIndexOptions?> propIndexOptions = default;
LocalJsonValue<Elastic.Clients.Elasticsearch.Id?> propInferenceId = default;
LocalJsonValue<System.Collections.Generic.IDictionary<string, string>?> propMeta = default;
Expand All @@ -47,6 +49,11 @@ public override Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty Read(
continue;
}

if (propFields.TryReadProperty(ref reader, options, PropFields, null))
{
continue;
}

if (propIndexOptions.TryReadProperty(ref reader, options, PropIndexOptions, null))
{
continue;
Expand Down Expand Up @@ -86,6 +93,7 @@ public override Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty Read(
return new Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance)
{
ChunkingSettings = propChunkingSettings.Value,
Fields = propFields.Value,
IndexOptions = propIndexOptions.Value,
InferenceId = propInferenceId.Value,
Meta = propMeta.Value,
Expand All @@ -97,6 +105,7 @@ public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clien
{
writer.WriteStartObject();
writer.WriteProperty(options, PropChunkingSettings, value.ChunkingSettings, null, null);
writer.WriteProperty(options, PropFields, value.Fields, null, null);
writer.WriteProperty(options, PropIndexOptions, value.IndexOptions, null, null);
writer.WriteProperty(options, PropInferenceId, value.InferenceId, null, null);
writer.WriteProperty(options, PropMeta, value.Meta, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, System.Collections.Generic.IDictionary<string, string>? v) => w.WriteDictionaryValue<string, string>(o, v, null, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ internal SemanticTextProperty(Elastic.Clients.Elasticsearch.Serialization.JsonCo
/// </summary>
public Elastic.Clients.Elasticsearch.Mapping.ChunkingSettings? ChunkingSettings { get; set; }

/// <summary>
/// <para>
/// Multi-fields allow the same string value to be indexed in multiple ways for different purposes, such as one
/// field for search and a multi-field for sorting and aggregations, or the same string value analyzed by different analyzers.
/// </para>
/// </summary>
public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; }

/// <summary>
/// <para>
/// Settings for index_options that override any defaults used by semantic_text, for example
Expand Down Expand Up @@ -126,6 +134,30 @@ public Elastic.Clients.Elasticsearch.Mapping.SemanticTextPropertyDescriptor<TDoc
return this;
}

/// <summary>
/// <para>
/// Multi-fields allow the same string value to be indexed in multiple ways for different purposes, such as one
/// field for search and a multi-field for sorting and aggregations, or the same string value analyzed by different analyzers.
/// </para>
/// </summary>
public Elastic.Clients.Elasticsearch.Mapping.SemanticTextPropertyDescriptor<TDocument> Fields(Elastic.Clients.Elasticsearch.Mapping.Properties? value)
{
Instance.Fields = value;
return this;
}

/// <summary>
/// <para>
/// Multi-fields allow the same string value to be indexed in multiple ways for different purposes, such as one
/// field for search and a multi-field for sorting and aggregations, or the same string value analyzed by different analyzers.
/// </para>
/// </summary>
public Elastic.Clients.Elasticsearch.Mapping.SemanticTextPropertyDescriptor<TDocument> Fields(System.Action<Elastic.Clients.Elasticsearch.Mapping.PropertiesDescriptor<TDocument>> action)
{
Instance.Fields = Elastic.Clients.Elasticsearch.Mapping.PropertiesDescriptor<TDocument>.Build(action);
return this;
}

/// <summary>
/// <para>
/// Settings for index_options that override any defaults used by semantic_text, for example
Expand Down Expand Up @@ -272,6 +304,42 @@ public Elastic.Clients.Elasticsearch.Mapping.SemanticTextPropertyDescriptor Chun
return this;
}

/// <summary>
/// <para>
/// Multi-fields allow the same string value to be indexed in multiple ways for different purposes, such as one
/// field for search and a multi-field for sorting and aggregations, or the same string value analyzed by different analyzers.
/// </para>
/// </summary>
public Elastic.Clients.Elasticsearch.Mapping.SemanticTextPropertyDescriptor Fields(Elastic.Clients.Elasticsearch.Mapping.Properties? value)
{
Instance.Fields = value;
return this;
}

/// <summary>
/// <para>
/// Multi-fields allow the same string value to be indexed in multiple ways for different purposes, such as one
/// field for search and a multi-field for sorting and aggregations, or the same string value analyzed by different analyzers.
/// </para>
/// </summary>
public Elastic.Clients.Elasticsearch.Mapping.SemanticTextPropertyDescriptor Fields(System.Action<Elastic.Clients.Elasticsearch.Mapping.PropertiesDescriptor> action)
{
Instance.Fields = Elastic.Clients.Elasticsearch.Mapping.PropertiesDescriptor.Build(action);
return this;
}

/// <summary>
/// <para>
/// Multi-fields allow the same string value to be indexed in multiple ways for different purposes, such as one
/// field for search and a multi-field for sorting and aggregations, or the same string value analyzed by different analyzers.
/// </para>
/// </summary>
public Elastic.Clients.Elasticsearch.Mapping.SemanticTextPropertyDescriptor Fields<T>(System.Action<Elastic.Clients.Elasticsearch.Mapping.PropertiesDescriptor<T>> action)
{
Instance.Fields = Elastic.Clients.Elasticsearch.Mapping.PropertiesDescriptor<T>.Build(action);
return this;
}

/// <summary>
/// <para>
/// Settings for index_options that override any defaults used by semantic_text, for example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed partial class TextEmbeddingConverter : System.Text.Json.Serializat
public override Elastic.Clients.Elasticsearch.TextEmbedding Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
{
reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject);
LocalJsonValue<string> propModelId = default;
LocalJsonValue<string?> propModelId = default;
LocalJsonValue<string> propModelText = default;
while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ namespace Elastic.Clients.Elasticsearch;
public sealed partial class TextEmbedding
{
[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public TextEmbedding(string modelId, string modelText)
public TextEmbedding(string modelText)
{
ModelId = modelId;
ModelText = modelText;
}
#if NET7_0_OR_GREATER
Expand All @@ -49,11 +48,13 @@ internal TextEmbedding(Elastic.Clients.Elasticsearch.Serialization.JsonConstruct
_ = sentinel;
}

public
#if NET7_0_OR_GREATER
required
#endif
string ModelId { get; set; }
/// <summary>
/// <para>
/// Model ID is required for all dense_vector fields but
/// may be inferred for semantic_text fields
/// </para>
/// </summary>
public string? ModelId { get; set; }
public
#if NET7_0_OR_GREATER
required
Expand All @@ -80,7 +81,13 @@ public TextEmbeddingDescriptor()
public static explicit operator Elastic.Clients.Elasticsearch.TextEmbeddingDescriptor(Elastic.Clients.Elasticsearch.TextEmbedding instance) => new Elastic.Clients.Elasticsearch.TextEmbeddingDescriptor(instance);
public static implicit operator Elastic.Clients.Elasticsearch.TextEmbedding(Elastic.Clients.Elasticsearch.TextEmbeddingDescriptor descriptor) => descriptor.Instance;

public Elastic.Clients.Elasticsearch.TextEmbeddingDescriptor ModelId(string value)
/// <summary>
/// <para>
/// Model ID is required for all dense_vector fields but
/// may be inferred for semantic_text fields
/// </para>
/// </summary>
public Elastic.Clients.Elasticsearch.TextEmbeddingDescriptor ModelId(string? value)
{
Instance.ModelId = value;
return this;
Expand Down
Loading