Skip to content

Fix source (de-)serialization #8076

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
Apr 4, 2024
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 @@ -3231,4 +3231,4 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o

writer.WriteEndObject();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind
/// <para>An artificial document (a document not present in the index) for which you want to retrieve term vectors.</para>
/// </summary>
[JsonInclude, JsonPropertyName("doc")]
[SourceConverter]
public TDocument? Doc { get; set; }

/// <summary>
Expand Down Expand Up @@ -297,7 +298,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (DocValue is not null)
{
writer.WritePropertyName("doc");
JsonSerializer.Serialize(writer, DocValue, options);
SourceSerialization.Serialize(DocValue, writer, settings.SourceSerializer);
}

if (FilterDescriptor is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E
/// <para>A partial update to an existing document.</para>
/// </summary>
[JsonInclude, JsonPropertyName("doc")]
[SourceConverter]
public TPartialDocument? Doc { get; set; }

/// <summary>
Expand Down Expand Up @@ -210,6 +211,7 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E
/// <para>If the document does not already exist, the contents of 'upsert' are inserted as a<br/>new document. If the document exists, the 'script' is executed.</para>
/// </summary>
[JsonInclude, JsonPropertyName("upsert")]
[SourceConverter]
public TDocument? Upsert { get; set; }
}

Expand Down Expand Up @@ -339,7 +341,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (DocValue is not null)
{
writer.WritePropertyName("doc");
JsonSerializer.Serialize(writer, DocValue, options);
SourceSerialization.Serialize(DocValue, writer, settings.SourceSerializer);
}

if (DocAsUpsertValue.HasValue)
Expand Down Expand Up @@ -369,7 +371,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (UpsertValue is not null)
{
writer.WritePropertyName("upsert");
JsonSerializer.Serialize(writer, UpsertValue, options);
SourceSerialization.Serialize(UpsertValue, writer, settings.SourceSerializer);
}

writer.WriteEndObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,31 +116,31 @@ public virtual Task<GetAsyncSearchResponse<TDocument>> GetAsync<TDocument>(GetAs
/// </summary>
public virtual Task<GetAsyncSearchResponse<TDocument>> GetAsync<TDocument>(Elastic.Clients.Elasticsearch.Serverless.Id id, CancellationToken cancellationToken = default)
{
var descriptor = new GetAsyncSearchRequestDescriptor(id);
var descriptor = new GetAsyncSearchRequestDescriptor<TDocument>(id);
descriptor.BeforeRequest();
return DoRequestAsync<GetAsyncSearchRequestDescriptor, GetAsyncSearchResponse<TDocument>, GetAsyncSearchRequestParameters>(descriptor, cancellationToken);
return DoRequestAsync<GetAsyncSearchRequestDescriptor<TDocument>, GetAsyncSearchResponse<TDocument>, GetAsyncSearchRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
/// <para>Retrieves the results of a previously submitted async search request given its ID.</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/8.13/async-search.html">Learn more about this API in the Elasticsearch documentation.</see></para>
/// </summary>
public virtual Task<GetAsyncSearchResponse<TDocument>> GetAsync<TDocument>(GetAsyncSearchRequestDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual Task<GetAsyncSearchResponse<TDocument>> GetAsync<TDocument>(GetAsyncSearchRequestDescriptor<TDocument> descriptor, CancellationToken cancellationToken = default)
{
descriptor.BeforeRequest();
return DoRequestAsync<GetAsyncSearchRequestDescriptor, GetAsyncSearchResponse<TDocument>, GetAsyncSearchRequestParameters>(descriptor, cancellationToken);
return DoRequestAsync<GetAsyncSearchRequestDescriptor<TDocument>, GetAsyncSearchResponse<TDocument>, GetAsyncSearchRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
/// <para>Retrieves the results of a previously submitted async search request given its ID.</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/8.13/async-search.html">Learn more about this API in the Elasticsearch documentation.</see></para>
/// </summary>
public virtual Task<GetAsyncSearchResponse<TDocument>> GetAsync<TDocument>(Elastic.Clients.Elasticsearch.Serverless.Id id, Action<GetAsyncSearchRequestDescriptor> configureRequest, CancellationToken cancellationToken = default)
public virtual Task<GetAsyncSearchResponse<TDocument>> GetAsync<TDocument>(Elastic.Clients.Elasticsearch.Serverless.Id id, Action<GetAsyncSearchRequestDescriptor<TDocument>> configureRequest, CancellationToken cancellationToken = default)
{
var descriptor = new GetAsyncSearchRequestDescriptor(id);
var descriptor = new GetAsyncSearchRequestDescriptor<TDocument>(id);
configureRequest?.Invoke(descriptor);
descriptor.BeforeRequest();
return DoRequestAsync<GetAsyncSearchRequestDescriptor, GetAsyncSearchResponse<TDocument>, GetAsyncSearchRequestParameters>(descriptor, cancellationToken);
return DoRequestAsync<GetAsyncSearchRequestDescriptor<TDocument>, GetAsyncSearchResponse<TDocument>, GetAsyncSearchRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public sealed partial class DateHistogramAggregation
/// <para>The sort order of the returned buckets.</para>
/// </summary>
[JsonInclude, JsonPropertyName("order")]
[SingleOrManyCollectionConverter(typeof(IReadOnlyDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>))]
public ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? Order { get; set; }
[SingleOrManyCollectionConverter(typeof(KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>))]
public ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? Order { get; set; }
[JsonInclude, JsonPropertyName("params")]
public IDictionary<string, object>? Params { get; set; }
[JsonInclude, JsonPropertyName("script")]
Expand Down Expand Up @@ -113,7 +113,7 @@ public DateHistogramAggregationDescriptor() : base()
private DateTimeOffset? MissingValue { get; set; }
private string? NameValue { get; set; }
private Elastic.Clients.Elasticsearch.Serverless.Duration? OffsetValue { get; set; }
private ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private IDictionary<string, object>? ParamsValue { get; set; }
private Elastic.Clients.Elasticsearch.Serverless.Script? ScriptValue { get; set; }
private string? TimeZoneValue { get; set; }
Expand Down Expand Up @@ -214,7 +214,7 @@ public DateHistogramAggregationDescriptor<TDocument> Offset(Elastic.Clients.Elas
/// <summary>
/// <para>The sort order of the returned buckets.</para>
/// </summary>
public DateHistogramAggregationDescriptor<TDocument> Order(ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
public DateHistogramAggregationDescriptor<TDocument> Order(ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
{
OrderValue = order;
return Self;
Expand Down Expand Up @@ -301,7 +301,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (OrderValue is not null)
{
writer.WritePropertyName("order");
SingleOrManySerializationHelper.Serialize<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
SingleOrManySerializationHelper.Serialize<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
}

if (ParamsValue is not null)
Expand Down Expand Up @@ -343,7 +343,7 @@ public DateHistogramAggregationDescriptor() : base()
private DateTimeOffset? MissingValue { get; set; }
private string? NameValue { get; set; }
private Elastic.Clients.Elasticsearch.Serverless.Duration? OffsetValue { get; set; }
private ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private IDictionary<string, object>? ParamsValue { get; set; }
private Elastic.Clients.Elasticsearch.Serverless.Script? ScriptValue { get; set; }
private string? TimeZoneValue { get; set; }
Expand Down Expand Up @@ -444,7 +444,7 @@ public DateHistogramAggregationDescriptor Offset(Elastic.Clients.Elasticsearch.S
/// <summary>
/// <para>The sort order of the returned buckets.</para>
/// </summary>
public DateHistogramAggregationDescriptor Order(ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
public DateHistogramAggregationDescriptor Order(ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
{
OrderValue = order;
return Self;
Expand Down Expand Up @@ -531,7 +531,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (OrderValue is not null)
{
writer.WritePropertyName("order");
SingleOrManySerializationHelper.Serialize<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
SingleOrManySerializationHelper.Serialize<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
}

if (ParamsValue is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public sealed partial class HistogramAggregation
/// <para>The sort order of the returned buckets.<br/>By default, the returned buckets are sorted by their key ascending.</para>
/// </summary>
[JsonInclude, JsonPropertyName("order")]
[SingleOrManyCollectionConverter(typeof(IReadOnlyDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>))]
public ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? Order { get; set; }
[SingleOrManyCollectionConverter(typeof(KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>))]
public ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? Order { get; set; }
[JsonInclude, JsonPropertyName("script")]
public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; }

Expand All @@ -94,7 +94,7 @@ public HistogramAggregationDescriptor() : base()
private double? MissingValue { get; set; }
private string? NameValue { get; set; }
private double? OffsetValue { get; set; }
private ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private Elastic.Clients.Elasticsearch.Serverless.Script? ScriptValue { get; set; }

/// <summary>
Expand Down Expand Up @@ -181,7 +181,7 @@ public HistogramAggregationDescriptor<TDocument> Offset(double? offset)
/// <summary>
/// <para>The sort order of the returned buckets.<br/>By default, the returned buckets are sorted by their key ascending.</para>
/// </summary>
public HistogramAggregationDescriptor<TDocument> Order(ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
public HistogramAggregationDescriptor<TDocument> Order(ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
{
OrderValue = order;
return Self;
Expand Down Expand Up @@ -247,7 +247,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (OrderValue is not null)
{
writer.WritePropertyName("order");
SingleOrManySerializationHelper.Serialize<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
SingleOrManySerializationHelper.Serialize<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
}

if (ScriptValue is not null)
Expand Down Expand Up @@ -276,7 +276,7 @@ public HistogramAggregationDescriptor() : base()
private double? MissingValue { get; set; }
private string? NameValue { get; set; }
private double? OffsetValue { get; set; }
private ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private Elastic.Clients.Elasticsearch.Serverless.Script? ScriptValue { get; set; }

/// <summary>
Expand Down Expand Up @@ -363,7 +363,7 @@ public HistogramAggregationDescriptor Offset(double? offset)
/// <summary>
/// <para>The sort order of the returned buckets.<br/>By default, the returned buckets are sorted by their key ascending.</para>
/// </summary>
public HistogramAggregationDescriptor Order(ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
public HistogramAggregationDescriptor Order(ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
{
OrderValue = order;
return Self;
Expand Down Expand Up @@ -429,7 +429,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (OrderValue is not null)
{
writer.WritePropertyName("order");
SingleOrManySerializationHelper.Serialize<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
SingleOrManySerializationHelper.Serialize<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
}

if (ScriptValue is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public sealed partial class MultiTermsAggregation
/// <para>Specifies the sort order of the buckets.<br/>Defaults to sorting by descending document count.</para>
/// </summary>
[JsonInclude, JsonPropertyName("order")]
[SingleOrManyCollectionConverter(typeof(IReadOnlyDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>))]
public ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? Order { get; set; }
[SingleOrManyCollectionConverter(typeof(KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>))]
public ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? Order { get; set; }

/// <summary>
/// <para>The minimum number of documents in a bucket on each shard for it to be returned.</para>
Expand Down Expand Up @@ -97,7 +97,7 @@ public MultiTermsAggregationDescriptor() : base()
private IDictionary<string, object>? MetaValue { get; set; }
private long? MinDocCountValue { get; set; }
private string? NameValue { get; set; }
private ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private long? ShardMinDocCountValue { get; set; }
private int? ShardSizeValue { get; set; }
private bool? ShowTermDocCountErrorValue { get; set; }
Expand Down Expand Up @@ -140,7 +140,7 @@ public MultiTermsAggregationDescriptor<TDocument> Name(string? name)
/// <summary>
/// <para>Specifies the sort order of the buckets.<br/>Defaults to sorting by descending document count.</para>
/// </summary>
public MultiTermsAggregationDescriptor<TDocument> Order(ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
public MultiTermsAggregationDescriptor<TDocument> Order(ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
{
OrderValue = order;
return Self;
Expand Down Expand Up @@ -251,7 +251,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (OrderValue is not null)
{
writer.WritePropertyName("order");
SingleOrManySerializationHelper.Serialize<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
SingleOrManySerializationHelper.Serialize<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
}

if (ShardMinDocCountValue.HasValue)
Expand Down Expand Up @@ -325,7 +325,7 @@ public MultiTermsAggregationDescriptor() : base()
private IDictionary<string, object>? MetaValue { get; set; }
private long? MinDocCountValue { get; set; }
private string? NameValue { get; set; }
private ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? OrderValue { get; set; }
private long? ShardMinDocCountValue { get; set; }
private int? ShardSizeValue { get; set; }
private bool? ShowTermDocCountErrorValue { get; set; }
Expand Down Expand Up @@ -368,7 +368,7 @@ public MultiTermsAggregationDescriptor Name(string? name)
/// <summary>
/// <para>Specifies the sort order of the buckets.<br/>Defaults to sorting by descending document count.</para>
/// </summary>
public MultiTermsAggregationDescriptor Order(ICollection<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
public MultiTermsAggregationDescriptor Order(ICollection<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>? order)
{
OrderValue = order;
return Self;
Expand Down Expand Up @@ -479,7 +479,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
if (OrderValue is not null)
{
writer.WritePropertyName("order");
SingleOrManySerializationHelper.Serialize<IDictionary<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
SingleOrManySerializationHelper.Serialize<KeyValuePair<Elastic.Clients.Elasticsearch.Serverless.Field, Elastic.Clients.Elasticsearch.Serverless.SortOrder>>(OrderValue, writer, options);
}

if (ShardMinDocCountValue.HasValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,4 +724,4 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o

writer.WriteEndObject();
}
}
}
Loading