From 747ce4aefcf75755612af1dd48e8db2e367be0d4 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Tue, 9 Apr 2024 15:34:35 +0200 Subject: [PATCH] Fix serialization of `MultisearchBody`/`MultisearchHeader` --- .../Types/Core/MSearch/MultisearchBody.g.cs | 2245 ++++++++++++++++- .../Types/Core/MSearch/MultisearchHeader.g.cs | 184 +- .../Types/Core/MSearch/MultisearchBody.g.cs | 2245 ++++++++++++++++- .../Types/Core/MSearch/MultisearchHeader.g.cs | 184 +- 4 files changed, 4646 insertions(+), 212 deletions(-) diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs index 1e36face2d7..9253f8586b1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs @@ -33,37 +33,7 @@ public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConve { if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); - IReadOnlyDictionary? aggregations = default; - Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? collapse = default; - IReadOnlyCollection? docvalueFields = default; - bool? explain = default; - IReadOnlyDictionary? ext = default; - IReadOnlyCollection? fields = default; - int? from = default; - Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? highlight = default; - IReadOnlyCollection>? indicesBoost = default; - IReadOnlyCollection? knn = default; - double? minScore = default; - Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? pit = default; - Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? postFilter = default; - bool? profile = default; - Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? query = default; - IReadOnlyCollection? rescore = default; - IReadOnlyDictionary? runtimeMappings = default; - IReadOnlyDictionary? scriptFields = default; - IReadOnlyCollection? searchAfter = default; - bool? seqNoPrimaryTerm = default; - int? size = default; - IReadOnlyCollection? sort = default; - Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? source = default; - IReadOnlyCollection? stats = default; - Elastic.Clients.Elasticsearch.Serverless.Fields? storedFields = default; - Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? suggest = default; - long? terminateAfter = default; - string? timeout = default; - bool? trackScores = default; - Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? trackTotalHits = default; - bool? version = default; + var variant = new MultisearchBody(); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -71,321 +41,2406 @@ public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConve var property = reader.GetString(); if (property == "aggregations" || property == "aggs") { - aggregations = JsonSerializer.Deserialize?>(ref reader, options); + variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "collapse") { - collapse = JsonSerializer.Deserialize(ref reader, options); + variant.Collapse = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "docvalue_fields") { - docvalueFields = JsonSerializer.Deserialize?>(ref reader, options); + variant.DocvalueFields = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "explain") { - explain = JsonSerializer.Deserialize(ref reader, options); + variant.Explain = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "ext") { - ext = JsonSerializer.Deserialize?>(ref reader, options); + variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "fields") { - fields = JsonSerializer.Deserialize?>(ref reader, options); + variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "from") { - from = JsonSerializer.Deserialize(ref reader, options); + variant.From = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "highlight") { - highlight = JsonSerializer.Deserialize(ref reader, options); + variant.Highlight = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "indices_boost") { - indicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); + variant.IndicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); continue; } if (property == "knn") { - knn = JsonSerializer.Deserialize?>(ref reader, options); + variant.Knn = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "min_score") { - minScore = JsonSerializer.Deserialize(ref reader, options); + variant.MinScore = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "pit") { - pit = JsonSerializer.Deserialize(ref reader, options); + variant.Pit = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "post_filter") { - postFilter = JsonSerializer.Deserialize(ref reader, options); + variant.PostFilter = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "profile") { - profile = JsonSerializer.Deserialize(ref reader, options); + variant.Profile = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "query") { - query = JsonSerializer.Deserialize(ref reader, options); + variant.Query = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "rescore") { - rescore = JsonSerializer.Deserialize?>(ref reader, options); + variant.Rescore = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "runtime_mappings") { - runtimeMappings = JsonSerializer.Deserialize?>(ref reader, options); + variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "script_fields") { - scriptFields = JsonSerializer.Deserialize?>(ref reader, options); + variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "search_after") { - searchAfter = JsonSerializer.Deserialize?>(ref reader, options); + variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "seq_no_primary_term") { - seqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); + variant.SeqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "size") { - size = JsonSerializer.Deserialize(ref reader, options); + variant.Size = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "sort") { - sort = JsonSerializer.Deserialize?>(ref reader, options); + variant.Sort = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "_source") { - source = JsonSerializer.Deserialize(ref reader, options); + variant.Source = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "stats") { - stats = JsonSerializer.Deserialize?>(ref reader, options); + variant.Stats = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "stored_fields") { - storedFields = JsonSerializer.Deserialize(ref reader, options); + variant.StoredFields = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "suggest") { - suggest = JsonSerializer.Deserialize(ref reader, options); + variant.Suggest = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "terminate_after") { - terminateAfter = JsonSerializer.Deserialize(ref reader, options); + variant.TerminateAfter = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "timeout") { - timeout = JsonSerializer.Deserialize(ref reader, options); + variant.Timeout = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "track_scores") { - trackScores = JsonSerializer.Deserialize(ref reader, options); + variant.TrackScores = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "track_total_hits") { - trackTotalHits = JsonSerializer.Deserialize(ref reader, options); + variant.TrackTotalHits = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "version") { - version = JsonSerializer.Deserialize(ref reader, options); + variant.Version = JsonSerializer.Deserialize(ref reader, options); continue; } } } - return new MultisearchBody { Aggregations = aggregations, Collapse = collapse, DocvalueFields = docvalueFields, Explain = explain, Ext = ext, Fields = fields, From = from, Highlight = highlight, IndicesBoost = indicesBoost, Knn = knn, MinScore = minScore, Pit = pit, PostFilter = postFilter, Profile = profile, Query = query, Rescore = rescore, RuntimeMappings = runtimeMappings, ScriptFields = scriptFields, SearchAfter = searchAfter, SeqNoPrimaryTerm = seqNoPrimaryTerm, Size = size, Sort = sort, Source = source, Stats = stats, StoredFields = storedFields, Suggest = suggest, TerminateAfter = terminateAfter, Timeout = timeout, TrackScores = trackScores, TrackTotalHits = trackTotalHits, Version = version }; + return variant; } public override void Write(Utf8JsonWriter writer, MultisearchBody value, JsonSerializerOptions options) { - throw new NotImplementedException("'MultisearchBody' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + + if (value.Collapse is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, value.Collapse, options); + } + + if (value.DocvalueFields is not null) + { + writer.WritePropertyName("docvalue_fields"); + JsonSerializer.Serialize(writer, value.DocvalueFields, options); + } + + if (value.Explain.HasValue) + { + writer.WritePropertyName("explain"); + writer.WriteBooleanValue(value.Explain.Value); + } + + if (value.Ext is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, value.Ext, options); + } + + if (value.Fields is not null) + { + writer.WritePropertyName("fields"); + JsonSerializer.Serialize(writer, value.Fields, options); + } + + if (value.From.HasValue) + { + writer.WritePropertyName("from"); + writer.WriteNumberValue(value.From.Value); + } + + if (value.Highlight is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, value.Highlight, options); + } + + if (value.IndicesBoost is not null) + { + writer.WritePropertyName("indices_boost"); + JsonSerializer.Serialize(writer, value.IndicesBoost, options); + } + + if (value.Knn is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, value.Knn, options); + } + + if (value.MinScore.HasValue) + { + writer.WritePropertyName("min_score"); + writer.WriteNumberValue(value.MinScore.Value); + } + + if (value.Pit is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, value.Pit, options); + } + + if (value.PostFilter is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, value.PostFilter, options); + } + + if (value.Profile.HasValue) + { + writer.WritePropertyName("profile"); + writer.WriteBooleanValue(value.Profile.Value); + } + + if (value.Query is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, value.Query, options); + } + + if (value.Rescore is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, value.Rescore, options); + } + + if (value.RuntimeMappings is not null) + { + writer.WritePropertyName("runtime_mappings"); + JsonSerializer.Serialize(writer, value.RuntimeMappings, options); + } + + if (value.ScriptFields is not null) + { + writer.WritePropertyName("script_fields"); + JsonSerializer.Serialize(writer, value.ScriptFields, options); + } + + if (value.SearchAfter is not null) + { + writer.WritePropertyName("search_after"); + JsonSerializer.Serialize(writer, value.SearchAfter, options); + } + + if (value.SeqNoPrimaryTerm.HasValue) + { + writer.WritePropertyName("seq_no_primary_term"); + writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); + } + + if (value.Size.HasValue) + { + writer.WritePropertyName("size"); + writer.WriteNumberValue(value.Size.Value); + } + + if (value.Sort is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, value.Sort, options); + } + + if (value.Source is not null) + { + writer.WritePropertyName("_source"); + JsonSerializer.Serialize(writer, value.Source, options); + } + + if (value.Stats is not null) + { + writer.WritePropertyName("stats"); + JsonSerializer.Serialize(writer, value.Stats, options); + } + + if (value.StoredFields is not null) + { + writer.WritePropertyName("stored_fields"); + JsonSerializer.Serialize(writer, value.StoredFields, options); + } + + if (value.Suggest is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, value.Suggest, options); + } + + if (value.TerminateAfter.HasValue) + { + writer.WritePropertyName("terminate_after"); + writer.WriteNumberValue(value.TerminateAfter.Value); + } + + if (!string.IsNullOrEmpty(value.Timeout)) + { + writer.WritePropertyName("timeout"); + writer.WriteStringValue(value.Timeout); + } + + if (value.TrackScores.HasValue) + { + writer.WritePropertyName("track_scores"); + writer.WriteBooleanValue(value.TrackScores.Value); + } + + if (value.TrackTotalHits is not null) + { + writer.WritePropertyName("track_total_hits"); + JsonSerializer.Serialize(writer, value.TrackTotalHits, options); + } + + if (value.Version.HasValue) + { + writer.WritePropertyName("version"); + writer.WriteBooleanValue(value.Version.Value); + } + + writer.WriteEndObject(); } } [JsonConverter(typeof(MultisearchBodyConverter))] public sealed partial class MultisearchBody { - public IReadOnlyDictionary? Aggregations { get; init; } - public Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? Collapse { get; init; } + public IDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? Collapse { get; set; } /// /// Array of wildcard (*) patterns. The request returns doc values for field
names matching these patterns in the hits.fields property of the response.
///
- public IReadOnlyCollection? DocvalueFields { get; init; } + public ICollection? DocvalueFields { get; set; } /// /// If true, returns detailed information about score computation as part of a hit. /// - public bool? Explain { get; init; } + public bool? Explain { get; set; } /// /// Configuration of search extensions defined by Elasticsearch plugins. /// - public IReadOnlyDictionary? Ext { get; init; } + public IDictionary? Ext { get; set; } /// /// Array of wildcard (*) patterns. The request returns values for field names
matching these patterns in the hits.fields property of the response.
///
- public IReadOnlyCollection? Fields { get; init; } + public ICollection? Fields { get; set; } /// /// Starting document offset. By default, you cannot page through more than 10,000
hits using the from and size parameters. To page through more hits, use the
search_after parameter.
///
- public int? From { get; init; } - public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? Highlight { get; init; } + public int? From { get; set; } + public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? Highlight { get; set; } /// /// Boosts the _score of documents from specified indices. /// - public IReadOnlyCollection>? IndicesBoost { get; init; } + public ICollection>? IndicesBoost { get; set; } /// /// Defines the approximate kNN search to run. /// - public IReadOnlyCollection? Knn { get; init; } + public ICollection? Knn { get; set; } /// /// Minimum _score for matching documents. Documents with a lower _score are
not included in the search results.
///
- public double? MinScore { get; init; } + public double? MinScore { get; set; } /// /// Limits the search to a point in time (PIT). If you provide a PIT, you
cannot specify an in the request path.
///
- public Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? Pit { get; init; } - public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? PostFilter { get; init; } - public bool? Profile { get; init; } + public Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? Pit { get; set; } + public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? PostFilter { get; set; } + public bool? Profile { get; set; } /// /// Defines the search definition using the Query DSL. /// - public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; init; } - public IReadOnlyCollection? Rescore { get; init; } + public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } + public ICollection? Rescore { get; set; } /// /// Defines one or more runtime fields in the search request. These fields take
precedence over mapped fields with the same name.
///
- public IReadOnlyDictionary? RuntimeMappings { get; init; } + public IDictionary? RuntimeMappings { get; set; } /// /// Retrieve a script evaluation (based on different fields) for each hit. /// - public IReadOnlyDictionary? ScriptFields { get; init; } - public IReadOnlyCollection? SearchAfter { get; init; } + public IDictionary? ScriptFields { get; set; } + public ICollection? SearchAfter { get; set; } /// /// If true, returns sequence number and primary term of the last modification
of each hit. See Optimistic concurrency control.
///
- public bool? SeqNoPrimaryTerm { get; init; } + public bool? SeqNoPrimaryTerm { get; set; } /// /// The number of hits to return. By default, you cannot page through more
than 10,000 hits using the from and size parameters. To page through more
hits, use the search_after parameter.
///
- public int? Size { get; init; } - public IReadOnlyCollection? Sort { get; init; } + public int? Size { get; set; } + public ICollection? Sort { get; set; } /// /// Indicates which source fields are returned for matching documents. These
fields are returned in the hits._source property of the search response.
///
- public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; init; } + public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; set; } /// /// Stats groups to associate with the search. Each group maintains a statistics
aggregation for its associated searches. You can retrieve these stats using
the indices stats API.
///
- public IReadOnlyCollection? Stats { get; init; } + public ICollection? Stats { get; set; } /// /// List of stored fields to return as part of a hit. If no fields are specified,
no stored fields are included in the response. If this field is specified, the _source
parameter defaults to false. You can pass _source: true to return both source fields
and stored fields in the search response.
///
- public Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFields { get; init; } - public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? Suggest { get; init; } + public Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFields { get; set; } + public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? Suggest { get; set; } /// /// Maximum number of documents to collect for each shard. If a query reaches this
limit, Elasticsearch terminates the query early. Elasticsearch collects documents
before sorting. Defaults to 0, which does not terminate query execution early.
///
- public long? TerminateAfter { get; init; } + public long? TerminateAfter { get; set; } /// /// Specifies the period of time to wait for a response from each shard. If no response
is received before the timeout expires, the request fails and returns an error.
Defaults to no timeout.
///
- public string? Timeout { get; init; } + public string? Timeout { get; set; } /// /// If true, calculate and return document scores, even if the scores are not used for sorting. /// - public bool? TrackScores { get; init; } + public bool? TrackScores { get; set; } /// /// Number of hits matching the query to count accurately. If true, the exact
number of hits is returned at the cost of some performance. If false, the
response does not include the total number of hits matching the query.
Defaults to 10,000 hits.
///
- public Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? TrackTotalHits { get; init; } + public Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? TrackTotalHits { get; set; } /// /// If true, returns document version as part of a hit. /// - public bool? Version { get; init; } + public bool? Version { get; set; } +} + +public sealed partial class MultisearchBodyDescriptor : SerializableDescriptor> +{ + internal MultisearchBodyDescriptor(Action> configure) => configure.Invoke(this); + + public MultisearchBodyDescriptor() : base() + { + } + + private IDictionary> AggregationsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? CollapseValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapseDescriptor CollapseDescriptor { get; set; } + private Action> CollapseDescriptorAction { get; set; } + private ICollection? DocvalueFieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor DocvalueFieldsDescriptor { get; set; } + private Action> DocvalueFieldsDescriptorAction { get; set; } + private Action>[] DocvalueFieldsDescriptorActions { get; set; } + private bool? ExplainValue { get; set; } + private IDictionary? ExtValue { get; set; } + private ICollection? FieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor FieldsDescriptor { get; set; } + private Action> FieldsDescriptorAction { get; set; } + private Action>[] FieldsDescriptorActions { get; set; } + private int? FromValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? HighlightValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlightDescriptor HighlightDescriptor { get; set; } + private Action> HighlightDescriptorAction { get; set; } + private ICollection>? IndicesBoostValue { get; set; } + private ICollection? KnnValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.KnnQueryDescriptor KnnDescriptor { get; set; } + private Action> KnnDescriptorAction { get; set; } + private Action>[] KnnDescriptorActions { get; set; } + private double? MinScoreValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? PitValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReferenceDescriptor PitDescriptor { get; set; } + private Action PitDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? PostFilterValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor PostFilterDescriptor { get; set; } + private Action> PostFilterDescriptorAction { get; set; } + private bool? ProfileValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? QueryValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor QueryDescriptor { get; set; } + private Action> QueryDescriptorAction { get; set; } + private ICollection? RescoreValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreDescriptor RescoreDescriptor { get; set; } + private Action> RescoreDescriptorAction { get; set; } + private Action>[] RescoreDescriptorActions { get; set; } + private IDictionary> RuntimeMappingsValue { get; set; } + private IDictionary ScriptFieldsValue { get; set; } + private ICollection? SearchAfterValue { get; set; } + private bool? SeqNoPrimaryTermValue { get; set; } + private int? SizeValue { get; set; } + private ICollection? SortValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.SortOptionsDescriptor SortDescriptor { get; set; } + private Action> SortDescriptorAction { get; set; } + private Action>[] SortDescriptorActions { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? SourceValue { get; set; } + private ICollection? StatsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? SuggestValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggesterDescriptor SuggestDescriptor { get; set; } + private Action> SuggestDescriptorAction { get; set; } + private long? TerminateAfterValue { get; set; } + private string? TimeoutValue { get; set; } + private bool? TrackScoresValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? TrackTotalHitsValue { get; set; } + private bool? VersionValue { get; set; } + + public MultisearchBodyDescriptor Aggregations(Func>, FluentDescriptorDictionary>> selector) + { + AggregationsValue = selector?.Invoke(new FluentDescriptorDictionary>()); + return Self; + } + + public MultisearchBodyDescriptor Collapse(Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? collapse) + { + CollapseDescriptor = null; + CollapseDescriptorAction = null; + CollapseValue = collapse; + return Self; + } + + public MultisearchBodyDescriptor Collapse(Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapseDescriptor descriptor) + { + CollapseValue = null; + CollapseDescriptorAction = null; + CollapseDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Collapse(Action> configure) + { + CollapseValue = null; + CollapseDescriptor = null; + CollapseDescriptorAction = configure; + return Self; + } + + /// + /// Array of wildcard (*) patterns. The request returns doc values for field
names matching these patterns in the hits.fields property of the response.
+ ///
+ public MultisearchBodyDescriptor DocvalueFields(ICollection? docvalueFields) + { + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsValue = docvalueFields; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor descriptor) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(Action> configure) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(params Action>[] configure) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = configure; + return Self; + } + + /// + /// If true, returns detailed information about score computation as part of a hit. + /// + public MultisearchBodyDescriptor Explain(bool? explain = true) + { + ExplainValue = explain; + return Self; + } + + /// + /// Configuration of search extensions defined by Elasticsearch plugins. + /// + public MultisearchBodyDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + /// + /// Array of wildcard (*) patterns. The request returns values for field names
matching these patterns in the hits.fields property of the response.
+ ///
+ public MultisearchBodyDescriptor Fields(ICollection? fields) + { + FieldsDescriptor = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = null; + FieldsValue = fields; + return Self; + } + + public MultisearchBodyDescriptor Fields(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor descriptor) + { + FieldsValue = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = null; + FieldsDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Fields(Action> configure) + { + FieldsValue = null; + FieldsDescriptor = null; + FieldsDescriptorActions = null; + FieldsDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Fields(params Action>[] configure) + { + FieldsValue = null; + FieldsDescriptor = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = configure; + return Self; + } + + /// + /// Starting document offset. By default, you cannot page through more than 10,000
hits using the from and size parameters. To page through more hits, use the
search_after parameter.
+ ///
+ public MultisearchBodyDescriptor From(int? from) + { + FromValue = from; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? highlight) + { + HighlightDescriptor = null; + HighlightDescriptorAction = null; + HighlightValue = highlight; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlightDescriptor descriptor) + { + HighlightValue = null; + HighlightDescriptorAction = null; + HighlightDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Action> configure) + { + HighlightValue = null; + HighlightDescriptor = null; + HighlightDescriptorAction = configure; + return Self; + } + + /// + /// Boosts the _score of documents from specified indices. + /// + public MultisearchBodyDescriptor IndicesBoost(ICollection>? indicesBoost) + { + IndicesBoostValue = indicesBoost; + return Self; + } + + /// + /// Defines the approximate kNN search to run. + /// + public MultisearchBodyDescriptor Knn(ICollection? knn) + { + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = null; + KnnValue = knn; + return Self; + } + + public MultisearchBodyDescriptor Knn(Elastic.Clients.Elasticsearch.Serverless.KnnQueryDescriptor descriptor) + { + KnnValue = null; + KnnDescriptorAction = null; + KnnDescriptorActions = null; + KnnDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Knn(Action> configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorActions = null; + KnnDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Knn(params Action>[] configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = configure; + return Self; + } + + /// + /// Minimum _score for matching documents. Documents with a lower _score are
not included in the search results.
+ ///
+ public MultisearchBodyDescriptor MinScore(double? minScore) + { + MinScoreValue = minScore; + return Self; + } + + /// + /// Limits the search to a point in time (PIT). If you provide a PIT, you
cannot specify an in the request path.
+ ///
+ public MultisearchBodyDescriptor Pit(Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? pit) + { + PitDescriptor = null; + PitDescriptorAction = null; + PitValue = pit; + return Self; + } + + public MultisearchBodyDescriptor Pit(Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReferenceDescriptor descriptor) + { + PitValue = null; + PitDescriptorAction = null; + PitDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Pit(Action configure) + { + PitValue = null; + PitDescriptor = null; + PitDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? postFilter) + { + PostFilterDescriptor = null; + PostFilterDescriptorAction = null; + PostFilterValue = postFilter; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor descriptor) + { + PostFilterValue = null; + PostFilterDescriptorAction = null; + PostFilterDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Action> configure) + { + PostFilterValue = null; + PostFilterDescriptor = null; + PostFilterDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Profile(bool? profile = true) + { + ProfileValue = profile; + return Self; + } + + /// + /// Defines the search definition using the Query DSL. + /// + public MultisearchBodyDescriptor Query(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? query) + { + QueryDescriptor = null; + QueryDescriptorAction = null; + QueryValue = query; + return Self; + } + + public MultisearchBodyDescriptor Query(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor descriptor) + { + QueryValue = null; + QueryDescriptorAction = null; + QueryDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Query(Action> configure) + { + QueryValue = null; + QueryDescriptor = null; + QueryDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Rescore(ICollection? rescore) + { + RescoreDescriptor = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = null; + RescoreValue = rescore; + return Self; + } + + public MultisearchBodyDescriptor Rescore(Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreDescriptor descriptor) + { + RescoreValue = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = null; + RescoreDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Rescore(Action> configure) + { + RescoreValue = null; + RescoreDescriptor = null; + RescoreDescriptorActions = null; + RescoreDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Rescore(params Action>[] configure) + { + RescoreValue = null; + RescoreDescriptor = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = configure; + return Self; + } + + /// + /// Defines one or more runtime fields in the search request. These fields take
precedence over mapped fields with the same name.
+ ///
+ public MultisearchBodyDescriptor RuntimeMappings(Func>, FluentDescriptorDictionary>> selector) + { + RuntimeMappingsValue = selector?.Invoke(new FluentDescriptorDictionary>()); + return Self; + } + + /// + /// Retrieve a script evaluation (based on different fields) for each hit. + /// + public MultisearchBodyDescriptor ScriptFields(Func, FluentDescriptorDictionary> selector) + { + ScriptFieldsValue = selector?.Invoke(new FluentDescriptorDictionary()); + return Self; + } + + public MultisearchBodyDescriptor SearchAfter(ICollection? searchAfter) + { + SearchAfterValue = searchAfter; + return Self; + } + + /// + /// If true, returns sequence number and primary term of the last modification
of each hit. See Optimistic concurrency control.
+ ///
+ public MultisearchBodyDescriptor SeqNoPrimaryTerm(bool? seqNoPrimaryTerm = true) + { + SeqNoPrimaryTermValue = seqNoPrimaryTerm; + return Self; + } + + /// + /// The number of hits to return. By default, you cannot page through more
than 10,000 hits using the from and size parameters. To page through more
hits, use the search_after parameter.
+ ///
+ public MultisearchBodyDescriptor Size(int? size) + { + SizeValue = size; + return Self; + } + + public MultisearchBodyDescriptor Sort(ICollection? sort) + { + SortDescriptor = null; + SortDescriptorAction = null; + SortDescriptorActions = null; + SortValue = sort; + return Self; + } + + public MultisearchBodyDescriptor Sort(Elastic.Clients.Elasticsearch.Serverless.SortOptionsDescriptor descriptor) + { + SortValue = null; + SortDescriptorAction = null; + SortDescriptorActions = null; + SortDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Sort(Action> configure) + { + SortValue = null; + SortDescriptor = null; + SortDescriptorActions = null; + SortDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Sort(params Action>[] configure) + { + SortValue = null; + SortDescriptor = null; + SortDescriptorAction = null; + SortDescriptorActions = configure; + return Self; + } + + /// + /// Indicates which source fields are returned for matching documents. These
fields are returned in the hits._source property of the search response.
+ ///
+ public MultisearchBodyDescriptor Source(Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? source) + { + SourceValue = source; + return Self; + } + + /// + /// Stats groups to associate with the search. Each group maintains a statistics
aggregation for its associated searches. You can retrieve these stats using
the indices stats API.
+ ///
+ public MultisearchBodyDescriptor Stats(ICollection? stats) + { + StatsValue = stats; + return Self; + } + + /// + /// List of stored fields to return as part of a hit. If no fields are specified,
no stored fields are included in the response. If this field is specified, the _source
parameter defaults to false. You can pass _source: true to return both source fields
and stored fields in the search response.
+ ///
+ public MultisearchBodyDescriptor StoredFields(Elastic.Clients.Elasticsearch.Serverless.Fields? storedFields) + { + StoredFieldsValue = storedFields; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? suggest) + { + SuggestDescriptor = null; + SuggestDescriptorAction = null; + SuggestValue = suggest; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggesterDescriptor descriptor) + { + SuggestValue = null; + SuggestDescriptorAction = null; + SuggestDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Action> configure) + { + SuggestValue = null; + SuggestDescriptor = null; + SuggestDescriptorAction = configure; + return Self; + } + + /// + /// Maximum number of documents to collect for each shard. If a query reaches this
limit, Elasticsearch terminates the query early. Elasticsearch collects documents
before sorting. Defaults to 0, which does not terminate query execution early.
+ ///
+ public MultisearchBodyDescriptor TerminateAfter(long? terminateAfter) + { + TerminateAfterValue = terminateAfter; + return Self; + } + + /// + /// Specifies the period of time to wait for a response from each shard. If no response
is received before the timeout expires, the request fails and returns an error.
Defaults to no timeout.
+ ///
+ public MultisearchBodyDescriptor Timeout(string? timeout) + { + TimeoutValue = timeout; + return Self; + } + + /// + /// If true, calculate and return document scores, even if the scores are not used for sorting. + /// + public MultisearchBodyDescriptor TrackScores(bool? trackScores = true) + { + TrackScoresValue = trackScores; + return Self; + } + + /// + /// Number of hits matching the query to count accurately. If true, the exact
number of hits is returned at the cost of some performance. If false, the
response does not include the total number of hits matching the query.
Defaults to 10,000 hits.
+ ///
+ public MultisearchBodyDescriptor TrackTotalHits(Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? trackTotalHits) + { + TrackTotalHitsValue = trackTotalHits; + return Self; + } + + /// + /// If true, returns document version as part of a hit. + /// + public MultisearchBodyDescriptor Version(bool? version = true) + { + VersionValue = version; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + if (CollapseDescriptor is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, CollapseDescriptor, options); + } + else if (CollapseDescriptorAction is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapseDescriptor(CollapseDescriptorAction), options); + } + else if (CollapseValue is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, CollapseValue, options); + } + + if (DocvalueFieldsDescriptor is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, DocvalueFieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (DocvalueFieldsDescriptorAction is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor(DocvalueFieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (DocvalueFieldsDescriptorActions is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + foreach (var action in DocvalueFieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (DocvalueFieldsValue is not null) + { + writer.WritePropertyName("docvalue_fields"); + JsonSerializer.Serialize(writer, DocvalueFieldsValue, options); + } + + if (ExplainValue.HasValue) + { + writer.WritePropertyName("explain"); + writer.WriteBooleanValue(ExplainValue.Value); + } + + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + + if (FieldsDescriptor is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, FieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (FieldsDescriptorAction is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor(FieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (FieldsDescriptorActions is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + foreach (var action in FieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (FieldsValue is not null) + { + writer.WritePropertyName("fields"); + JsonSerializer.Serialize(writer, FieldsValue, options); + } + + if (FromValue.HasValue) + { + writer.WritePropertyName("from"); + writer.WriteNumberValue(FromValue.Value); + } + + if (HighlightDescriptor is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, HighlightDescriptor, options); + } + else if (HighlightDescriptorAction is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlightDescriptor(HighlightDescriptorAction), options); + } + else if (HighlightValue is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, HighlightValue, options); + } + + if (IndicesBoostValue is not null) + { + writer.WritePropertyName("indices_boost"); + JsonSerializer.Serialize(writer, IndicesBoostValue, options); + } + + if (KnnDescriptor is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, KnnDescriptor, options); + } + else if (KnnDescriptorAction is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.KnnQueryDescriptor(KnnDescriptorAction), options); + } + else if (KnnDescriptorActions is not null) + { + writer.WritePropertyName("knn"); + if (KnnDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in KnnDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.KnnQueryDescriptor(action), options); + } + + if (KnnDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (KnnValue is not null) + { + writer.WritePropertyName("knn"); + SingleOrManySerializationHelper.Serialize(KnnValue, writer, options); + } + + if (MinScoreValue.HasValue) + { + writer.WritePropertyName("min_score"); + writer.WriteNumberValue(MinScoreValue.Value); + } + + if (PitDescriptor is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, PitDescriptor, options); + } + else if (PitDescriptorAction is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReferenceDescriptor(PitDescriptorAction), options); + } + else if (PitValue is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, PitValue, options); + } + + if (PostFilterDescriptor is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, PostFilterDescriptor, options); + } + else if (PostFilterDescriptorAction is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor(PostFilterDescriptorAction), options); + } + else if (PostFilterValue is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, PostFilterValue, options); + } + + if (ProfileValue.HasValue) + { + writer.WritePropertyName("profile"); + writer.WriteBooleanValue(ProfileValue.Value); + } + + if (QueryDescriptor is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, QueryDescriptor, options); + } + else if (QueryDescriptorAction is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor(QueryDescriptorAction), options); + } + else if (QueryValue is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, QueryValue, options); + } + + if (RescoreDescriptor is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, RescoreDescriptor, options); + } + else if (RescoreDescriptorAction is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreDescriptor(RescoreDescriptorAction), options); + } + else if (RescoreDescriptorActions is not null) + { + writer.WritePropertyName("rescore"); + if (RescoreDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in RescoreDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreDescriptor(action), options); + } + + if (RescoreDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (RescoreValue is not null) + { + writer.WritePropertyName("rescore"); + SingleOrManySerializationHelper.Serialize(RescoreValue, writer, options); + } + + if (RuntimeMappingsValue is not null) + { + writer.WritePropertyName("runtime_mappings"); + JsonSerializer.Serialize(writer, RuntimeMappingsValue, options); + } + + if (ScriptFieldsValue is not null) + { + writer.WritePropertyName("script_fields"); + JsonSerializer.Serialize(writer, ScriptFieldsValue, options); + } + + if (SearchAfterValue is not null) + { + writer.WritePropertyName("search_after"); + JsonSerializer.Serialize(writer, SearchAfterValue, options); + } + + if (SeqNoPrimaryTermValue.HasValue) + { + writer.WritePropertyName("seq_no_primary_term"); + writer.WriteBooleanValue(SeqNoPrimaryTermValue.Value); + } + + if (SizeValue.HasValue) + { + writer.WritePropertyName("size"); + writer.WriteNumberValue(SizeValue.Value); + } + + if (SortDescriptor is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, SortDescriptor, options); + } + else if (SortDescriptorAction is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.SortOptionsDescriptor(SortDescriptorAction), options); + } + else if (SortDescriptorActions is not null) + { + writer.WritePropertyName("sort"); + if (SortDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in SortDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.SortOptionsDescriptor(action), options); + } + + if (SortDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (SortValue is not null) + { + writer.WritePropertyName("sort"); + SingleOrManySerializationHelper.Serialize(SortValue, writer, options); + } + + if (SourceValue is not null) + { + writer.WritePropertyName("_source"); + JsonSerializer.Serialize(writer, SourceValue, options); + } + + if (StatsValue is not null) + { + writer.WritePropertyName("stats"); + JsonSerializer.Serialize(writer, StatsValue, options); + } + + if (StoredFieldsValue is not null) + { + writer.WritePropertyName("stored_fields"); + JsonSerializer.Serialize(writer, StoredFieldsValue, options); + } + + if (SuggestDescriptor is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, SuggestDescriptor, options); + } + else if (SuggestDescriptorAction is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggesterDescriptor(SuggestDescriptorAction), options); + } + else if (SuggestValue is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, SuggestValue, options); + } + + if (TerminateAfterValue.HasValue) + { + writer.WritePropertyName("terminate_after"); + writer.WriteNumberValue(TerminateAfterValue.Value); + } + + if (!string.IsNullOrEmpty(TimeoutValue)) + { + writer.WritePropertyName("timeout"); + writer.WriteStringValue(TimeoutValue); + } + + if (TrackScoresValue.HasValue) + { + writer.WritePropertyName("track_scores"); + writer.WriteBooleanValue(TrackScoresValue.Value); + } + + if (TrackTotalHitsValue is not null) + { + writer.WritePropertyName("track_total_hits"); + JsonSerializer.Serialize(writer, TrackTotalHitsValue, options); + } + + if (VersionValue.HasValue) + { + writer.WritePropertyName("version"); + writer.WriteBooleanValue(VersionValue.Value); + } + + writer.WriteEndObject(); + } +} + +public sealed partial class MultisearchBodyDescriptor : SerializableDescriptor +{ + internal MultisearchBodyDescriptor(Action configure) => configure.Invoke(this); + + public MultisearchBodyDescriptor() : base() + { + } + + private IDictionary AggregationsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? CollapseValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapseDescriptor CollapseDescriptor { get; set; } + private Action CollapseDescriptorAction { get; set; } + private ICollection? DocvalueFieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor DocvalueFieldsDescriptor { get; set; } + private Action DocvalueFieldsDescriptorAction { get; set; } + private Action[] DocvalueFieldsDescriptorActions { get; set; } + private bool? ExplainValue { get; set; } + private IDictionary? ExtValue { get; set; } + private ICollection? FieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor FieldsDescriptor { get; set; } + private Action FieldsDescriptorAction { get; set; } + private Action[] FieldsDescriptorActions { get; set; } + private int? FromValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? HighlightValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlightDescriptor HighlightDescriptor { get; set; } + private Action HighlightDescriptorAction { get; set; } + private ICollection>? IndicesBoostValue { get; set; } + private ICollection? KnnValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.KnnQueryDescriptor KnnDescriptor { get; set; } + private Action KnnDescriptorAction { get; set; } + private Action[] KnnDescriptorActions { get; set; } + private double? MinScoreValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? PitValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReferenceDescriptor PitDescriptor { get; set; } + private Action PitDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? PostFilterValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor PostFilterDescriptor { get; set; } + private Action PostFilterDescriptorAction { get; set; } + private bool? ProfileValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? QueryValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor QueryDescriptor { get; set; } + private Action QueryDescriptorAction { get; set; } + private ICollection? RescoreValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreDescriptor RescoreDescriptor { get; set; } + private Action RescoreDescriptorAction { get; set; } + private Action[] RescoreDescriptorActions { get; set; } + private IDictionary RuntimeMappingsValue { get; set; } + private IDictionary ScriptFieldsValue { get; set; } + private ICollection? SearchAfterValue { get; set; } + private bool? SeqNoPrimaryTermValue { get; set; } + private int? SizeValue { get; set; } + private ICollection? SortValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.SortOptionsDescriptor SortDescriptor { get; set; } + private Action SortDescriptorAction { get; set; } + private Action[] SortDescriptorActions { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? SourceValue { get; set; } + private ICollection? StatsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? SuggestValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggesterDescriptor SuggestDescriptor { get; set; } + private Action SuggestDescriptorAction { get; set; } + private long? TerminateAfterValue { get; set; } + private string? TimeoutValue { get; set; } + private bool? TrackScoresValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? TrackTotalHitsValue { get; set; } + private bool? VersionValue { get; set; } + + public MultisearchBodyDescriptor Aggregations(Func, FluentDescriptorDictionary> selector) + { + AggregationsValue = selector?.Invoke(new FluentDescriptorDictionary()); + return Self; + } + + public MultisearchBodyDescriptor Collapse(Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? collapse) + { + CollapseDescriptor = null; + CollapseDescriptorAction = null; + CollapseValue = collapse; + return Self; + } + + public MultisearchBodyDescriptor Collapse(Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapseDescriptor descriptor) + { + CollapseValue = null; + CollapseDescriptorAction = null; + CollapseDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Collapse(Action configure) + { + CollapseValue = null; + CollapseDescriptor = null; + CollapseDescriptorAction = configure; + return Self; + } + + /// + /// Array of wildcard (*) patterns. The request returns doc values for field
names matching these patterns in the hits.fields property of the response.
+ ///
+ public MultisearchBodyDescriptor DocvalueFields(ICollection? docvalueFields) + { + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsValue = docvalueFields; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor descriptor) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(Action configure) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(params Action[] configure) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = configure; + return Self; + } + + /// + /// If true, returns detailed information about score computation as part of a hit. + /// + public MultisearchBodyDescriptor Explain(bool? explain = true) + { + ExplainValue = explain; + return Self; + } + + /// + /// Configuration of search extensions defined by Elasticsearch plugins. + /// + public MultisearchBodyDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + /// + /// Array of wildcard (*) patterns. The request returns values for field names
matching these patterns in the hits.fields property of the response.
+ ///
+ public MultisearchBodyDescriptor Fields(ICollection? fields) + { + FieldsDescriptor = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = null; + FieldsValue = fields; + return Self; + } + + public MultisearchBodyDescriptor Fields(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor descriptor) + { + FieldsValue = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = null; + FieldsDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Fields(Action configure) + { + FieldsValue = null; + FieldsDescriptor = null; + FieldsDescriptorActions = null; + FieldsDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Fields(params Action[] configure) + { + FieldsValue = null; + FieldsDescriptor = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = configure; + return Self; + } + + /// + /// Starting document offset. By default, you cannot page through more than 10,000
hits using the from and size parameters. To page through more hits, use the
search_after parameter.
+ ///
+ public MultisearchBodyDescriptor From(int? from) + { + FromValue = from; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? highlight) + { + HighlightDescriptor = null; + HighlightDescriptorAction = null; + HighlightValue = highlight; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlightDescriptor descriptor) + { + HighlightValue = null; + HighlightDescriptorAction = null; + HighlightDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Action configure) + { + HighlightValue = null; + HighlightDescriptor = null; + HighlightDescriptorAction = configure; + return Self; + } + + /// + /// Boosts the _score of documents from specified indices. + /// + public MultisearchBodyDescriptor IndicesBoost(ICollection>? indicesBoost) + { + IndicesBoostValue = indicesBoost; + return Self; + } + + /// + /// Defines the approximate kNN search to run. + /// + public MultisearchBodyDescriptor Knn(ICollection? knn) + { + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = null; + KnnValue = knn; + return Self; + } + + public MultisearchBodyDescriptor Knn(Elastic.Clients.Elasticsearch.Serverless.KnnQueryDescriptor descriptor) + { + KnnValue = null; + KnnDescriptorAction = null; + KnnDescriptorActions = null; + KnnDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Knn(Action configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorActions = null; + KnnDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Knn(params Action[] configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = configure; + return Self; + } + + /// + /// Minimum _score for matching documents. Documents with a lower _score are
not included in the search results.
+ ///
+ public MultisearchBodyDescriptor MinScore(double? minScore) + { + MinScoreValue = minScore; + return Self; + } + + /// + /// Limits the search to a point in time (PIT). If you provide a PIT, you
cannot specify an in the request path.
+ ///
+ public MultisearchBodyDescriptor Pit(Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? pit) + { + PitDescriptor = null; + PitDescriptorAction = null; + PitValue = pit; + return Self; + } + + public MultisearchBodyDescriptor Pit(Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReferenceDescriptor descriptor) + { + PitValue = null; + PitDescriptorAction = null; + PitDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Pit(Action configure) + { + PitValue = null; + PitDescriptor = null; + PitDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? postFilter) + { + PostFilterDescriptor = null; + PostFilterDescriptorAction = null; + PostFilterValue = postFilter; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor descriptor) + { + PostFilterValue = null; + PostFilterDescriptorAction = null; + PostFilterDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Action configure) + { + PostFilterValue = null; + PostFilterDescriptor = null; + PostFilterDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Profile(bool? profile = true) + { + ProfileValue = profile; + return Self; + } + + /// + /// Defines the search definition using the Query DSL. + /// + public MultisearchBodyDescriptor Query(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? query) + { + QueryDescriptor = null; + QueryDescriptorAction = null; + QueryValue = query; + return Self; + } + + public MultisearchBodyDescriptor Query(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor descriptor) + { + QueryValue = null; + QueryDescriptorAction = null; + QueryDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Query(Action configure) + { + QueryValue = null; + QueryDescriptor = null; + QueryDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Rescore(ICollection? rescore) + { + RescoreDescriptor = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = null; + RescoreValue = rescore; + return Self; + } + + public MultisearchBodyDescriptor Rescore(Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreDescriptor descriptor) + { + RescoreValue = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = null; + RescoreDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Rescore(Action configure) + { + RescoreValue = null; + RescoreDescriptor = null; + RescoreDescriptorActions = null; + RescoreDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Rescore(params Action[] configure) + { + RescoreValue = null; + RescoreDescriptor = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = configure; + return Self; + } + + /// + /// Defines one or more runtime fields in the search request. These fields take
precedence over mapped fields with the same name.
+ ///
+ public MultisearchBodyDescriptor RuntimeMappings(Func, FluentDescriptorDictionary> selector) + { + RuntimeMappingsValue = selector?.Invoke(new FluentDescriptorDictionary()); + return Self; + } + + /// + /// Retrieve a script evaluation (based on different fields) for each hit. + /// + public MultisearchBodyDescriptor ScriptFields(Func, FluentDescriptorDictionary> selector) + { + ScriptFieldsValue = selector?.Invoke(new FluentDescriptorDictionary()); + return Self; + } + + public MultisearchBodyDescriptor SearchAfter(ICollection? searchAfter) + { + SearchAfterValue = searchAfter; + return Self; + } + + /// + /// If true, returns sequence number and primary term of the last modification
of each hit. See Optimistic concurrency control.
+ ///
+ public MultisearchBodyDescriptor SeqNoPrimaryTerm(bool? seqNoPrimaryTerm = true) + { + SeqNoPrimaryTermValue = seqNoPrimaryTerm; + return Self; + } + + /// + /// The number of hits to return. By default, you cannot page through more
than 10,000 hits using the from and size parameters. To page through more
hits, use the search_after parameter.
+ ///
+ public MultisearchBodyDescriptor Size(int? size) + { + SizeValue = size; + return Self; + } + + public MultisearchBodyDescriptor Sort(ICollection? sort) + { + SortDescriptor = null; + SortDescriptorAction = null; + SortDescriptorActions = null; + SortValue = sort; + return Self; + } + + public MultisearchBodyDescriptor Sort(Elastic.Clients.Elasticsearch.Serverless.SortOptionsDescriptor descriptor) + { + SortValue = null; + SortDescriptorAction = null; + SortDescriptorActions = null; + SortDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Sort(Action configure) + { + SortValue = null; + SortDescriptor = null; + SortDescriptorActions = null; + SortDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Sort(params Action[] configure) + { + SortValue = null; + SortDescriptor = null; + SortDescriptorAction = null; + SortDescriptorActions = configure; + return Self; + } + + /// + /// Indicates which source fields are returned for matching documents. These
fields are returned in the hits._source property of the search response.
+ ///
+ public MultisearchBodyDescriptor Source(Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? source) + { + SourceValue = source; + return Self; + } + + /// + /// Stats groups to associate with the search. Each group maintains a statistics
aggregation for its associated searches. You can retrieve these stats using
the indices stats API.
+ ///
+ public MultisearchBodyDescriptor Stats(ICollection? stats) + { + StatsValue = stats; + return Self; + } + + /// + /// List of stored fields to return as part of a hit. If no fields are specified,
no stored fields are included in the response. If this field is specified, the _source
parameter defaults to false. You can pass _source: true to return both source fields
and stored fields in the search response.
+ ///
+ public MultisearchBodyDescriptor StoredFields(Elastic.Clients.Elasticsearch.Serverless.Fields? storedFields) + { + StoredFieldsValue = storedFields; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? suggest) + { + SuggestDescriptor = null; + SuggestDescriptorAction = null; + SuggestValue = suggest; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggesterDescriptor descriptor) + { + SuggestValue = null; + SuggestDescriptorAction = null; + SuggestDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Action configure) + { + SuggestValue = null; + SuggestDescriptor = null; + SuggestDescriptorAction = configure; + return Self; + } + + /// + /// Maximum number of documents to collect for each shard. If a query reaches this
limit, Elasticsearch terminates the query early. Elasticsearch collects documents
before sorting. Defaults to 0, which does not terminate query execution early.
+ ///
+ public MultisearchBodyDescriptor TerminateAfter(long? terminateAfter) + { + TerminateAfterValue = terminateAfter; + return Self; + } + + /// + /// Specifies the period of time to wait for a response from each shard. If no response
is received before the timeout expires, the request fails and returns an error.
Defaults to no timeout.
+ ///
+ public MultisearchBodyDescriptor Timeout(string? timeout) + { + TimeoutValue = timeout; + return Self; + } + + /// + /// If true, calculate and return document scores, even if the scores are not used for sorting. + /// + public MultisearchBodyDescriptor TrackScores(bool? trackScores = true) + { + TrackScoresValue = trackScores; + return Self; + } + + /// + /// Number of hits matching the query to count accurately. If true, the exact
number of hits is returned at the cost of some performance. If false, the
response does not include the total number of hits matching the query.
Defaults to 10,000 hits.
+ ///
+ public MultisearchBodyDescriptor TrackTotalHits(Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? trackTotalHits) + { + TrackTotalHitsValue = trackTotalHits; + return Self; + } + + /// + /// If true, returns document version as part of a hit. + /// + public MultisearchBodyDescriptor Version(bool? version = true) + { + VersionValue = version; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + if (CollapseDescriptor is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, CollapseDescriptor, options); + } + else if (CollapseDescriptorAction is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapseDescriptor(CollapseDescriptorAction), options); + } + else if (CollapseValue is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, CollapseValue, options); + } + + if (DocvalueFieldsDescriptor is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, DocvalueFieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (DocvalueFieldsDescriptorAction is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor(DocvalueFieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (DocvalueFieldsDescriptorActions is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + foreach (var action in DocvalueFieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (DocvalueFieldsValue is not null) + { + writer.WritePropertyName("docvalue_fields"); + JsonSerializer.Serialize(writer, DocvalueFieldsValue, options); + } + + if (ExplainValue.HasValue) + { + writer.WritePropertyName("explain"); + writer.WriteBooleanValue(ExplainValue.Value); + } + + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + + if (FieldsDescriptor is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, FieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (FieldsDescriptorAction is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor(FieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (FieldsDescriptorActions is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + foreach (var action in FieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormatDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (FieldsValue is not null) + { + writer.WritePropertyName("fields"); + JsonSerializer.Serialize(writer, FieldsValue, options); + } + + if (FromValue.HasValue) + { + writer.WritePropertyName("from"); + writer.WriteNumberValue(FromValue.Value); + } + + if (HighlightDescriptor is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, HighlightDescriptor, options); + } + else if (HighlightDescriptorAction is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlightDescriptor(HighlightDescriptorAction), options); + } + else if (HighlightValue is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, HighlightValue, options); + } + + if (IndicesBoostValue is not null) + { + writer.WritePropertyName("indices_boost"); + JsonSerializer.Serialize(writer, IndicesBoostValue, options); + } + + if (KnnDescriptor is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, KnnDescriptor, options); + } + else if (KnnDescriptorAction is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.KnnQueryDescriptor(KnnDescriptorAction), options); + } + else if (KnnDescriptorActions is not null) + { + writer.WritePropertyName("knn"); + if (KnnDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in KnnDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.KnnQueryDescriptor(action), options); + } + + if (KnnDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (KnnValue is not null) + { + writer.WritePropertyName("knn"); + SingleOrManySerializationHelper.Serialize(KnnValue, writer, options); + } + + if (MinScoreValue.HasValue) + { + writer.WritePropertyName("min_score"); + writer.WriteNumberValue(MinScoreValue.Value); + } + + if (PitDescriptor is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, PitDescriptor, options); + } + else if (PitDescriptorAction is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReferenceDescriptor(PitDescriptorAction), options); + } + else if (PitValue is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, PitValue, options); + } + + if (PostFilterDescriptor is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, PostFilterDescriptor, options); + } + else if (PostFilterDescriptorAction is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor(PostFilterDescriptorAction), options); + } + else if (PostFilterValue is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, PostFilterValue, options); + } + + if (ProfileValue.HasValue) + { + writer.WritePropertyName("profile"); + writer.WriteBooleanValue(ProfileValue.Value); + } + + if (QueryDescriptor is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, QueryDescriptor, options); + } + else if (QueryDescriptorAction is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor(QueryDescriptorAction), options); + } + else if (QueryValue is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, QueryValue, options); + } + + if (RescoreDescriptor is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, RescoreDescriptor, options); + } + else if (RescoreDescriptorAction is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreDescriptor(RescoreDescriptorAction), options); + } + else if (RescoreDescriptorActions is not null) + { + writer.WritePropertyName("rescore"); + if (RescoreDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in RescoreDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreDescriptor(action), options); + } + + if (RescoreDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (RescoreValue is not null) + { + writer.WritePropertyName("rescore"); + SingleOrManySerializationHelper.Serialize(RescoreValue, writer, options); + } + + if (RuntimeMappingsValue is not null) + { + writer.WritePropertyName("runtime_mappings"); + JsonSerializer.Serialize(writer, RuntimeMappingsValue, options); + } + + if (ScriptFieldsValue is not null) + { + writer.WritePropertyName("script_fields"); + JsonSerializer.Serialize(writer, ScriptFieldsValue, options); + } + + if (SearchAfterValue is not null) + { + writer.WritePropertyName("search_after"); + JsonSerializer.Serialize(writer, SearchAfterValue, options); + } + + if (SeqNoPrimaryTermValue.HasValue) + { + writer.WritePropertyName("seq_no_primary_term"); + writer.WriteBooleanValue(SeqNoPrimaryTermValue.Value); + } + + if (SizeValue.HasValue) + { + writer.WritePropertyName("size"); + writer.WriteNumberValue(SizeValue.Value); + } + + if (SortDescriptor is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, SortDescriptor, options); + } + else if (SortDescriptorAction is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.SortOptionsDescriptor(SortDescriptorAction), options); + } + else if (SortDescriptorActions is not null) + { + writer.WritePropertyName("sort"); + if (SortDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in SortDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.SortOptionsDescriptor(action), options); + } + + if (SortDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (SortValue is not null) + { + writer.WritePropertyName("sort"); + SingleOrManySerializationHelper.Serialize(SortValue, writer, options); + } + + if (SourceValue is not null) + { + writer.WritePropertyName("_source"); + JsonSerializer.Serialize(writer, SourceValue, options); + } + + if (StatsValue is not null) + { + writer.WritePropertyName("stats"); + JsonSerializer.Serialize(writer, StatsValue, options); + } + + if (StoredFieldsValue is not null) + { + writer.WritePropertyName("stored_fields"); + JsonSerializer.Serialize(writer, StoredFieldsValue, options); + } + + if (SuggestDescriptor is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, SuggestDescriptor, options); + } + else if (SuggestDescriptorAction is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggesterDescriptor(SuggestDescriptorAction), options); + } + else if (SuggestValue is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, SuggestValue, options); + } + + if (TerminateAfterValue.HasValue) + { + writer.WritePropertyName("terminate_after"); + writer.WriteNumberValue(TerminateAfterValue.Value); + } + + if (!string.IsNullOrEmpty(TimeoutValue)) + { + writer.WritePropertyName("timeout"); + writer.WriteStringValue(TimeoutValue); + } + + if (TrackScoresValue.HasValue) + { + writer.WritePropertyName("track_scores"); + writer.WriteBooleanValue(TrackScoresValue.Value); + } + + if (TrackTotalHitsValue is not null) + { + writer.WritePropertyName("track_total_hits"); + JsonSerializer.Serialize(writer, TrackTotalHitsValue, options); + } + + if (VersionValue.HasValue) + { + writer.WritePropertyName("version"); + writer.WriteBooleanValue(VersionValue.Value); + } + + writer.WriteEndObject(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs index 24aae6ace5c..e681824741f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs @@ -33,26 +33,188 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.MSearch; public sealed partial class MultisearchHeader { [JsonInclude, JsonPropertyName("allow_no_indices")] - public bool? AllowNoIndices { get; init; } + public bool? AllowNoIndices { get; set; } [JsonInclude, JsonPropertyName("allow_partial_search_results")] - public bool? AllowPartialSearchResults { get; init; } + public bool? AllowPartialSearchResults { get; set; } [JsonInclude, JsonPropertyName("ccs_minimize_roundtrips")] - public bool? CcsMinimizeRoundtrips { get; init; } + public bool? CcsMinimizeRoundtrips { get; set; } [JsonInclude, JsonPropertyName("expand_wildcards")] [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard))] - public IReadOnlyCollection? ExpandWildcards { get; init; } + public ICollection? ExpandWildcards { get; set; } [JsonInclude, JsonPropertyName("ignore_throttled")] - public bool? IgnoreThrottled { get; init; } + public bool? IgnoreThrottled { get; set; } [JsonInclude, JsonPropertyName("ignore_unavailable")] - public bool? IgnoreUnavailable { get; init; } + public bool? IgnoreUnavailable { get; set; } [JsonInclude, JsonPropertyName("index")] - public Elastic.Clients.Elasticsearch.Serverless.Indices? Indices { get; init; } + public Elastic.Clients.Elasticsearch.Serverless.Indices? Indices { get; set; } [JsonInclude, JsonPropertyName("preference")] - public string? Preference { get; init; } + public string? Preference { get; set; } [JsonInclude, JsonPropertyName("request_cache")] - public bool? RequestCache { get; init; } + public bool? RequestCache { get; set; } [JsonInclude, JsonPropertyName("routing")] - public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; init; } + public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; set; } [JsonInclude, JsonPropertyName("search_type")] - public Elastic.Clients.Elasticsearch.Serverless.SearchType? SearchType { get; init; } + public Elastic.Clients.Elasticsearch.Serverless.SearchType? SearchType { get; set; } +} + +/// +/// Contains parameters used to limit or change the subsequent search body request. +/// +public sealed partial class MultisearchHeaderDescriptor : SerializableDescriptor +{ + internal MultisearchHeaderDescriptor(Action configure) => configure.Invoke(this); + + public MultisearchHeaderDescriptor() : base() + { + } + + private bool? AllowNoIndicesValue { get; set; } + private bool? AllowPartialSearchResultsValue { get; set; } + private bool? CcsMinimizeRoundtripsValue { get; set; } + private ICollection? ExpandWildcardsValue { get; set; } + private bool? IgnoreThrottledValue { get; set; } + private bool? IgnoreUnavailableValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Indices? IndicesValue { get; set; } + private string? PreferenceValue { get; set; } + private bool? RequestCacheValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Routing? RoutingValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.SearchType? SearchTypeValue { get; set; } + + public MultisearchHeaderDescriptor AllowNoIndices(bool? allowNoIndices = true) + { + AllowNoIndicesValue = allowNoIndices; + return Self; + } + + public MultisearchHeaderDescriptor AllowPartialSearchResults(bool? allowPartialSearchResults = true) + { + AllowPartialSearchResultsValue = allowPartialSearchResults; + return Self; + } + + public MultisearchHeaderDescriptor CcsMinimizeRoundtrips(bool? ccsMinimizeRoundtrips = true) + { + CcsMinimizeRoundtripsValue = ccsMinimizeRoundtrips; + return Self; + } + + public MultisearchHeaderDescriptor ExpandWildcards(ICollection? expandWildcards) + { + ExpandWildcardsValue = expandWildcards; + return Self; + } + + public MultisearchHeaderDescriptor IgnoreThrottled(bool? ignoreThrottled = true) + { + IgnoreThrottledValue = ignoreThrottled; + return Self; + } + + public MultisearchHeaderDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) + { + IgnoreUnavailableValue = ignoreUnavailable; + return Self; + } + + public MultisearchHeaderDescriptor Indices(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) + { + IndicesValue = indices; + return Self; + } + + public MultisearchHeaderDescriptor Preference(string? preference) + { + PreferenceValue = preference; + return Self; + } + + public MultisearchHeaderDescriptor RequestCache(bool? requestCache = true) + { + RequestCacheValue = requestCache; + return Self; + } + + public MultisearchHeaderDescriptor Routing(Elastic.Clients.Elasticsearch.Serverless.Routing? routing) + { + RoutingValue = routing; + return Self; + } + + public MultisearchHeaderDescriptor SearchType(Elastic.Clients.Elasticsearch.Serverless.SearchType? searchType) + { + SearchTypeValue = searchType; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (AllowNoIndicesValue.HasValue) + { + writer.WritePropertyName("allow_no_indices"); + writer.WriteBooleanValue(AllowNoIndicesValue.Value); + } + + if (AllowPartialSearchResultsValue.HasValue) + { + writer.WritePropertyName("allow_partial_search_results"); + writer.WriteBooleanValue(AllowPartialSearchResultsValue.Value); + } + + if (CcsMinimizeRoundtripsValue.HasValue) + { + writer.WritePropertyName("ccs_minimize_roundtrips"); + writer.WriteBooleanValue(CcsMinimizeRoundtripsValue.Value); + } + + if (ExpandWildcardsValue is not null) + { + writer.WritePropertyName("expand_wildcards"); + SingleOrManySerializationHelper.Serialize(ExpandWildcardsValue, writer, options); + } + + if (IgnoreThrottledValue.HasValue) + { + writer.WritePropertyName("ignore_throttled"); + writer.WriteBooleanValue(IgnoreThrottledValue.Value); + } + + if (IgnoreUnavailableValue.HasValue) + { + writer.WritePropertyName("ignore_unavailable"); + writer.WriteBooleanValue(IgnoreUnavailableValue.Value); + } + + if (IndicesValue is not null) + { + writer.WritePropertyName("index"); + JsonSerializer.Serialize(writer, IndicesValue, options); + } + + if (!string.IsNullOrEmpty(PreferenceValue)) + { + writer.WritePropertyName("preference"); + writer.WriteStringValue(PreferenceValue); + } + + if (RequestCacheValue.HasValue) + { + writer.WritePropertyName("request_cache"); + writer.WriteBooleanValue(RequestCacheValue.Value); + } + + if (RoutingValue is not null) + { + writer.WritePropertyName("routing"); + JsonSerializer.Serialize(writer, RoutingValue, options); + } + + if (SearchTypeValue is not null) + { + writer.WritePropertyName("search_type"); + JsonSerializer.Serialize(writer, SearchTypeValue, options); + } + + writer.WriteEndObject(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs index a3f21bdd0fe..8a04472629b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs @@ -33,37 +33,7 @@ public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConve { if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); - IReadOnlyDictionary? aggregations = default; - Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? collapse = default; - IReadOnlyCollection? docvalueFields = default; - bool? explain = default; - IReadOnlyDictionary? ext = default; - IReadOnlyCollection? fields = default; - int? from = default; - Elastic.Clients.Elasticsearch.Core.Search.Highlight? highlight = default; - IReadOnlyCollection>? indicesBoost = default; - IReadOnlyCollection? knn = default; - double? minScore = default; - Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? pit = default; - Elastic.Clients.Elasticsearch.QueryDsl.Query? postFilter = default; - bool? profile = default; - Elastic.Clients.Elasticsearch.QueryDsl.Query? query = default; - IReadOnlyCollection? rescore = default; - IReadOnlyDictionary? runtimeMappings = default; - IReadOnlyDictionary? scriptFields = default; - IReadOnlyCollection? searchAfter = default; - bool? seqNoPrimaryTerm = default; - int? size = default; - IReadOnlyCollection? sort = default; - Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? source = default; - IReadOnlyCollection? stats = default; - Elastic.Clients.Elasticsearch.Fields? storedFields = default; - Elastic.Clients.Elasticsearch.Core.Search.Suggester? suggest = default; - long? terminateAfter = default; - string? timeout = default; - bool? trackScores = default; - Elastic.Clients.Elasticsearch.Core.Search.TrackHits? trackTotalHits = default; - bool? version = default; + var variant = new MultisearchBody(); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -71,321 +41,2406 @@ public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConve var property = reader.GetString(); if (property == "aggregations" || property == "aggs") { - aggregations = JsonSerializer.Deserialize?>(ref reader, options); + variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "collapse") { - collapse = JsonSerializer.Deserialize(ref reader, options); + variant.Collapse = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "docvalue_fields") { - docvalueFields = JsonSerializer.Deserialize?>(ref reader, options); + variant.DocvalueFields = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "explain") { - explain = JsonSerializer.Deserialize(ref reader, options); + variant.Explain = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "ext") { - ext = JsonSerializer.Deserialize?>(ref reader, options); + variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "fields") { - fields = JsonSerializer.Deserialize?>(ref reader, options); + variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "from") { - from = JsonSerializer.Deserialize(ref reader, options); + variant.From = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "highlight") { - highlight = JsonSerializer.Deserialize(ref reader, options); + variant.Highlight = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "indices_boost") { - indicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); + variant.IndicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); continue; } if (property == "knn") { - knn = JsonSerializer.Deserialize?>(ref reader, options); + variant.Knn = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "min_score") { - minScore = JsonSerializer.Deserialize(ref reader, options); + variant.MinScore = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "pit") { - pit = JsonSerializer.Deserialize(ref reader, options); + variant.Pit = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "post_filter") { - postFilter = JsonSerializer.Deserialize(ref reader, options); + variant.PostFilter = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "profile") { - profile = JsonSerializer.Deserialize(ref reader, options); + variant.Profile = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "query") { - query = JsonSerializer.Deserialize(ref reader, options); + variant.Query = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "rescore") { - rescore = JsonSerializer.Deserialize?>(ref reader, options); + variant.Rescore = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "runtime_mappings") { - runtimeMappings = JsonSerializer.Deserialize?>(ref reader, options); + variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "script_fields") { - scriptFields = JsonSerializer.Deserialize?>(ref reader, options); + variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "search_after") { - searchAfter = JsonSerializer.Deserialize?>(ref reader, options); + variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "seq_no_primary_term") { - seqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); + variant.SeqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "size") { - size = JsonSerializer.Deserialize(ref reader, options); + variant.Size = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "sort") { - sort = JsonSerializer.Deserialize?>(ref reader, options); + variant.Sort = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "_source") { - source = JsonSerializer.Deserialize(ref reader, options); + variant.Source = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "stats") { - stats = JsonSerializer.Deserialize?>(ref reader, options); + variant.Stats = JsonSerializer.Deserialize?>(ref reader, options); continue; } if (property == "stored_fields") { - storedFields = JsonSerializer.Deserialize(ref reader, options); + variant.StoredFields = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "suggest") { - suggest = JsonSerializer.Deserialize(ref reader, options); + variant.Suggest = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "terminate_after") { - terminateAfter = JsonSerializer.Deserialize(ref reader, options); + variant.TerminateAfter = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "timeout") { - timeout = JsonSerializer.Deserialize(ref reader, options); + variant.Timeout = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "track_scores") { - trackScores = JsonSerializer.Deserialize(ref reader, options); + variant.TrackScores = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "track_total_hits") { - trackTotalHits = JsonSerializer.Deserialize(ref reader, options); + variant.TrackTotalHits = JsonSerializer.Deserialize(ref reader, options); continue; } if (property == "version") { - version = JsonSerializer.Deserialize(ref reader, options); + variant.Version = JsonSerializer.Deserialize(ref reader, options); continue; } } } - return new MultisearchBody { Aggregations = aggregations, Collapse = collapse, DocvalueFields = docvalueFields, Explain = explain, Ext = ext, Fields = fields, From = from, Highlight = highlight, IndicesBoost = indicesBoost, Knn = knn, MinScore = minScore, Pit = pit, PostFilter = postFilter, Profile = profile, Query = query, Rescore = rescore, RuntimeMappings = runtimeMappings, ScriptFields = scriptFields, SearchAfter = searchAfter, SeqNoPrimaryTerm = seqNoPrimaryTerm, Size = size, Sort = sort, Source = source, Stats = stats, StoredFields = storedFields, Suggest = suggest, TerminateAfter = terminateAfter, Timeout = timeout, TrackScores = trackScores, TrackTotalHits = trackTotalHits, Version = version }; + return variant; } public override void Write(Utf8JsonWriter writer, MultisearchBody value, JsonSerializerOptions options) { - throw new NotImplementedException("'MultisearchBody' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + if (value.Aggregations is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, value.Aggregations, options); + } + + if (value.Collapse is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, value.Collapse, options); + } + + if (value.DocvalueFields is not null) + { + writer.WritePropertyName("docvalue_fields"); + JsonSerializer.Serialize(writer, value.DocvalueFields, options); + } + + if (value.Explain.HasValue) + { + writer.WritePropertyName("explain"); + writer.WriteBooleanValue(value.Explain.Value); + } + + if (value.Ext is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, value.Ext, options); + } + + if (value.Fields is not null) + { + writer.WritePropertyName("fields"); + JsonSerializer.Serialize(writer, value.Fields, options); + } + + if (value.From.HasValue) + { + writer.WritePropertyName("from"); + writer.WriteNumberValue(value.From.Value); + } + + if (value.Highlight is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, value.Highlight, options); + } + + if (value.IndicesBoost is not null) + { + writer.WritePropertyName("indices_boost"); + JsonSerializer.Serialize(writer, value.IndicesBoost, options); + } + + if (value.Knn is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, value.Knn, options); + } + + if (value.MinScore.HasValue) + { + writer.WritePropertyName("min_score"); + writer.WriteNumberValue(value.MinScore.Value); + } + + if (value.Pit is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, value.Pit, options); + } + + if (value.PostFilter is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, value.PostFilter, options); + } + + if (value.Profile.HasValue) + { + writer.WritePropertyName("profile"); + writer.WriteBooleanValue(value.Profile.Value); + } + + if (value.Query is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, value.Query, options); + } + + if (value.Rescore is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, value.Rescore, options); + } + + if (value.RuntimeMappings is not null) + { + writer.WritePropertyName("runtime_mappings"); + JsonSerializer.Serialize(writer, value.RuntimeMappings, options); + } + + if (value.ScriptFields is not null) + { + writer.WritePropertyName("script_fields"); + JsonSerializer.Serialize(writer, value.ScriptFields, options); + } + + if (value.SearchAfter is not null) + { + writer.WritePropertyName("search_after"); + JsonSerializer.Serialize(writer, value.SearchAfter, options); + } + + if (value.SeqNoPrimaryTerm.HasValue) + { + writer.WritePropertyName("seq_no_primary_term"); + writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); + } + + if (value.Size.HasValue) + { + writer.WritePropertyName("size"); + writer.WriteNumberValue(value.Size.Value); + } + + if (value.Sort is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, value.Sort, options); + } + + if (value.Source is not null) + { + writer.WritePropertyName("_source"); + JsonSerializer.Serialize(writer, value.Source, options); + } + + if (value.Stats is not null) + { + writer.WritePropertyName("stats"); + JsonSerializer.Serialize(writer, value.Stats, options); + } + + if (value.StoredFields is not null) + { + writer.WritePropertyName("stored_fields"); + JsonSerializer.Serialize(writer, value.StoredFields, options); + } + + if (value.Suggest is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, value.Suggest, options); + } + + if (value.TerminateAfter.HasValue) + { + writer.WritePropertyName("terminate_after"); + writer.WriteNumberValue(value.TerminateAfter.Value); + } + + if (!string.IsNullOrEmpty(value.Timeout)) + { + writer.WritePropertyName("timeout"); + writer.WriteStringValue(value.Timeout); + } + + if (value.TrackScores.HasValue) + { + writer.WritePropertyName("track_scores"); + writer.WriteBooleanValue(value.TrackScores.Value); + } + + if (value.TrackTotalHits is not null) + { + writer.WritePropertyName("track_total_hits"); + JsonSerializer.Serialize(writer, value.TrackTotalHits, options); + } + + if (value.Version.HasValue) + { + writer.WritePropertyName("version"); + writer.WriteBooleanValue(value.Version.Value); + } + + writer.WriteEndObject(); } } [JsonConverter(typeof(MultisearchBodyConverter))] public sealed partial class MultisearchBody { - public IReadOnlyDictionary? Aggregations { get; init; } - public Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? Collapse { get; init; } + public IDictionary? Aggregations { get; set; } + public Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? Collapse { get; set; } /// /// Array of wildcard (*) patterns. The request returns doc values for field
names matching these patterns in the hits.fields property of the response.
///
- public IReadOnlyCollection? DocvalueFields { get; init; } + public ICollection? DocvalueFields { get; set; } /// /// If true, returns detailed information about score computation as part of a hit. /// - public bool? Explain { get; init; } + public bool? Explain { get; set; } /// /// Configuration of search extensions defined by Elasticsearch plugins. /// - public IReadOnlyDictionary? Ext { get; init; } + public IDictionary? Ext { get; set; } /// /// Array of wildcard (*) patterns. The request returns values for field names
matching these patterns in the hits.fields property of the response.
///
- public IReadOnlyCollection? Fields { get; init; } + public ICollection? Fields { get; set; } /// /// Starting document offset. By default, you cannot page through more than 10,000
hits using the from and size parameters. To page through more hits, use the
search_after parameter.
///
- public int? From { get; init; } - public Elastic.Clients.Elasticsearch.Core.Search.Highlight? Highlight { get; init; } + public int? From { get; set; } + public Elastic.Clients.Elasticsearch.Core.Search.Highlight? Highlight { get; set; } /// /// Boosts the _score of documents from specified indices. /// - public IReadOnlyCollection>? IndicesBoost { get; init; } + public ICollection>? IndicesBoost { get; set; } /// /// Defines the approximate kNN search to run. /// - public IReadOnlyCollection? Knn { get; init; } + public ICollection? Knn { get; set; } /// /// Minimum _score for matching documents. Documents with a lower _score are
not included in the search results.
///
- public double? MinScore { get; init; } + public double? MinScore { get; set; } /// /// Limits the search to a point in time (PIT). If you provide a PIT, you
cannot specify an in the request path.
///
- public Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? Pit { get; init; } - public Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilter { get; init; } - public bool? Profile { get; init; } + public Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? Pit { get; set; } + public Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilter { get; set; } + public bool? Profile { get; set; } /// /// Defines the search definition using the Query DSL. /// - public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; init; } - public IReadOnlyCollection? Rescore { get; init; } + public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } + public ICollection? Rescore { get; set; } /// /// Defines one or more runtime fields in the search request. These fields take
precedence over mapped fields with the same name.
///
- public IReadOnlyDictionary? RuntimeMappings { get; init; } + public IDictionary? RuntimeMappings { get; set; } /// /// Retrieve a script evaluation (based on different fields) for each hit. /// - public IReadOnlyDictionary? ScriptFields { get; init; } - public IReadOnlyCollection? SearchAfter { get; init; } + public IDictionary? ScriptFields { get; set; } + public ICollection? SearchAfter { get; set; } /// /// If true, returns sequence number and primary term of the last modification
of each hit. See Optimistic concurrency control.
///
- public bool? SeqNoPrimaryTerm { get; init; } + public bool? SeqNoPrimaryTerm { get; set; } /// /// The number of hits to return. By default, you cannot page through more
than 10,000 hits using the from and size parameters. To page through more
hits, use the search_after parameter.
///
- public int? Size { get; init; } - public IReadOnlyCollection? Sort { get; init; } + public int? Size { get; set; } + public ICollection? Sort { get; set; } /// /// Indicates which source fields are returned for matching documents. These
fields are returned in the hits._source property of the search response.
///
- public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; init; } + public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// /// Stats groups to associate with the search. Each group maintains a statistics
aggregation for its associated searches. You can retrieve these stats using
the indices stats API.
///
- public IReadOnlyCollection? Stats { get; init; } + public ICollection? Stats { get; set; } /// /// List of stored fields to return as part of a hit. If no fields are specified,
no stored fields are included in the response. If this field is specified, the _source
parameter defaults to false. You can pass _source: true to return both source fields
and stored fields in the search response.
///
- public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; init; } - public Elastic.Clients.Elasticsearch.Core.Search.Suggester? Suggest { get; init; } + public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; set; } + public Elastic.Clients.Elasticsearch.Core.Search.Suggester? Suggest { get; set; } /// /// Maximum number of documents to collect for each shard. If a query reaches this
limit, Elasticsearch terminates the query early. Elasticsearch collects documents
before sorting. Defaults to 0, which does not terminate query execution early.
///
- public long? TerminateAfter { get; init; } + public long? TerminateAfter { get; set; } /// /// Specifies the period of time to wait for a response from each shard. If no response
is received before the timeout expires, the request fails and returns an error.
Defaults to no timeout.
///
- public string? Timeout { get; init; } + public string? Timeout { get; set; } /// /// If true, calculate and return document scores, even if the scores are not used for sorting. /// - public bool? TrackScores { get; init; } + public bool? TrackScores { get; set; } /// /// Number of hits matching the query to count accurately. If true, the exact
number of hits is returned at the cost of some performance. If false, the
response does not include the total number of hits matching the query.
Defaults to 10,000 hits.
///
- public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; init; } + public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; set; } /// /// If true, returns document version as part of a hit. /// - public bool? Version { get; init; } + public bool? Version { get; set; } +} + +public sealed partial class MultisearchBodyDescriptor : SerializableDescriptor> +{ + internal MultisearchBodyDescriptor(Action> configure) => configure.Invoke(this); + + public MultisearchBodyDescriptor() : base() + { + } + + private IDictionary> AggregationsValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? CollapseValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.FieldCollapseDescriptor CollapseDescriptor { get; set; } + private Action> CollapseDescriptorAction { get; set; } + private ICollection? DocvalueFieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor DocvalueFieldsDescriptor { get; set; } + private Action> DocvalueFieldsDescriptorAction { get; set; } + private Action>[] DocvalueFieldsDescriptorActions { get; set; } + private bool? ExplainValue { get; set; } + private IDictionary? ExtValue { get; set; } + private ICollection? FieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor FieldsDescriptor { get; set; } + private Action> FieldsDescriptorAction { get; set; } + private Action>[] FieldsDescriptorActions { get; set; } + private int? FromValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.Highlight? HighlightValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.HighlightDescriptor HighlightDescriptor { get; set; } + private Action> HighlightDescriptorAction { get; set; } + private ICollection>? IndicesBoostValue { get; set; } + private ICollection? KnnValue { get; set; } + private Elastic.Clients.Elasticsearch.KnnQueryDescriptor KnnDescriptor { get; set; } + private Action> KnnDescriptorAction { get; set; } + private Action>[] KnnDescriptorActions { get; set; } + private double? MinScoreValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? PitValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReferenceDescriptor PitDescriptor { get; set; } + private Action PitDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilterValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor PostFilterDescriptor { get; set; } + private Action> PostFilterDescriptorAction { get; set; } + private bool? ProfileValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.Query? QueryValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor QueryDescriptor { get; set; } + private Action> QueryDescriptorAction { get; set; } + private ICollection? RescoreValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.RescoreDescriptor RescoreDescriptor { get; set; } + private Action> RescoreDescriptorAction { get; set; } + private Action>[] RescoreDescriptorActions { get; set; } + private IDictionary> RuntimeMappingsValue { get; set; } + private IDictionary ScriptFieldsValue { get; set; } + private ICollection? SearchAfterValue { get; set; } + private bool? SeqNoPrimaryTermValue { get; set; } + private int? SizeValue { get; set; } + private ICollection? SortValue { get; set; } + private Elastic.Clients.Elasticsearch.SortOptionsDescriptor SortDescriptor { get; set; } + private Action> SortDescriptorAction { get; set; } + private Action>[] SortDescriptorActions { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? SourceValue { get; set; } + private ICollection? StatsValue { get; set; } + private Elastic.Clients.Elasticsearch.Fields? StoredFieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.Suggester? SuggestValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.SuggesterDescriptor SuggestDescriptor { get; set; } + private Action> SuggestDescriptorAction { get; set; } + private long? TerminateAfterValue { get; set; } + private string? TimeoutValue { get; set; } + private bool? TrackScoresValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHitsValue { get; set; } + private bool? VersionValue { get; set; } + + public MultisearchBodyDescriptor Aggregations(Func>, FluentDescriptorDictionary>> selector) + { + AggregationsValue = selector?.Invoke(new FluentDescriptorDictionary>()); + return Self; + } + + public MultisearchBodyDescriptor Collapse(Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? collapse) + { + CollapseDescriptor = null; + CollapseDescriptorAction = null; + CollapseValue = collapse; + return Self; + } + + public MultisearchBodyDescriptor Collapse(Elastic.Clients.Elasticsearch.Core.Search.FieldCollapseDescriptor descriptor) + { + CollapseValue = null; + CollapseDescriptorAction = null; + CollapseDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Collapse(Action> configure) + { + CollapseValue = null; + CollapseDescriptor = null; + CollapseDescriptorAction = configure; + return Self; + } + + /// + /// Array of wildcard (*) patterns. The request returns doc values for field
names matching these patterns in the hits.fields property of the response.
+ ///
+ public MultisearchBodyDescriptor DocvalueFields(ICollection? docvalueFields) + { + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsValue = docvalueFields; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor descriptor) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(Action> configure) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(params Action>[] configure) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = configure; + return Self; + } + + /// + /// If true, returns detailed information about score computation as part of a hit. + /// + public MultisearchBodyDescriptor Explain(bool? explain = true) + { + ExplainValue = explain; + return Self; + } + + /// + /// Configuration of search extensions defined by Elasticsearch plugins. + /// + public MultisearchBodyDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + /// + /// Array of wildcard (*) patterns. The request returns values for field names
matching these patterns in the hits.fields property of the response.
+ ///
+ public MultisearchBodyDescriptor Fields(ICollection? fields) + { + FieldsDescriptor = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = null; + FieldsValue = fields; + return Self; + } + + public MultisearchBodyDescriptor Fields(Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor descriptor) + { + FieldsValue = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = null; + FieldsDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Fields(Action> configure) + { + FieldsValue = null; + FieldsDescriptor = null; + FieldsDescriptorActions = null; + FieldsDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Fields(params Action>[] configure) + { + FieldsValue = null; + FieldsDescriptor = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = configure; + return Self; + } + + /// + /// Starting document offset. By default, you cannot page through more than 10,000
hits using the from and size parameters. To page through more hits, use the
search_after parameter.
+ ///
+ public MultisearchBodyDescriptor From(int? from) + { + FromValue = from; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Elastic.Clients.Elasticsearch.Core.Search.Highlight? highlight) + { + HighlightDescriptor = null; + HighlightDescriptorAction = null; + HighlightValue = highlight; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Elastic.Clients.Elasticsearch.Core.Search.HighlightDescriptor descriptor) + { + HighlightValue = null; + HighlightDescriptorAction = null; + HighlightDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Action> configure) + { + HighlightValue = null; + HighlightDescriptor = null; + HighlightDescriptorAction = configure; + return Self; + } + + /// + /// Boosts the _score of documents from specified indices. + /// + public MultisearchBodyDescriptor IndicesBoost(ICollection>? indicesBoost) + { + IndicesBoostValue = indicesBoost; + return Self; + } + + /// + /// Defines the approximate kNN search to run. + /// + public MultisearchBodyDescriptor Knn(ICollection? knn) + { + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = null; + KnnValue = knn; + return Self; + } + + public MultisearchBodyDescriptor Knn(Elastic.Clients.Elasticsearch.KnnQueryDescriptor descriptor) + { + KnnValue = null; + KnnDescriptorAction = null; + KnnDescriptorActions = null; + KnnDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Knn(Action> configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorActions = null; + KnnDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Knn(params Action>[] configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = configure; + return Self; + } + + /// + /// Minimum _score for matching documents. Documents with a lower _score are
not included in the search results.
+ ///
+ public MultisearchBodyDescriptor MinScore(double? minScore) + { + MinScoreValue = minScore; + return Self; + } + + /// + /// Limits the search to a point in time (PIT). If you provide a PIT, you
cannot specify an in the request path.
+ ///
+ public MultisearchBodyDescriptor Pit(Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? pit) + { + PitDescriptor = null; + PitDescriptorAction = null; + PitValue = pit; + return Self; + } + + public MultisearchBodyDescriptor Pit(Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReferenceDescriptor descriptor) + { + PitValue = null; + PitDescriptorAction = null; + PitDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Pit(Action configure) + { + PitValue = null; + PitDescriptor = null; + PitDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Elastic.Clients.Elasticsearch.QueryDsl.Query? postFilter) + { + PostFilterDescriptor = null; + PostFilterDescriptorAction = null; + PostFilterValue = postFilter; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor descriptor) + { + PostFilterValue = null; + PostFilterDescriptorAction = null; + PostFilterDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Action> configure) + { + PostFilterValue = null; + PostFilterDescriptor = null; + PostFilterDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Profile(bool? profile = true) + { + ProfileValue = profile; + return Self; + } + + /// + /// Defines the search definition using the Query DSL. + /// + public MultisearchBodyDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.Query? query) + { + QueryDescriptor = null; + QueryDescriptorAction = null; + QueryValue = query; + return Self; + } + + public MultisearchBodyDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor descriptor) + { + QueryValue = null; + QueryDescriptorAction = null; + QueryDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Query(Action> configure) + { + QueryValue = null; + QueryDescriptor = null; + QueryDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Rescore(ICollection? rescore) + { + RescoreDescriptor = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = null; + RescoreValue = rescore; + return Self; + } + + public MultisearchBodyDescriptor Rescore(Elastic.Clients.Elasticsearch.Core.Search.RescoreDescriptor descriptor) + { + RescoreValue = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = null; + RescoreDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Rescore(Action> configure) + { + RescoreValue = null; + RescoreDescriptor = null; + RescoreDescriptorActions = null; + RescoreDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Rescore(params Action>[] configure) + { + RescoreValue = null; + RescoreDescriptor = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = configure; + return Self; + } + + /// + /// Defines one or more runtime fields in the search request. These fields take
precedence over mapped fields with the same name.
+ ///
+ public MultisearchBodyDescriptor RuntimeMappings(Func>, FluentDescriptorDictionary>> selector) + { + RuntimeMappingsValue = selector?.Invoke(new FluentDescriptorDictionary>()); + return Self; + } + + /// + /// Retrieve a script evaluation (based on different fields) for each hit. + /// + public MultisearchBodyDescriptor ScriptFields(Func, FluentDescriptorDictionary> selector) + { + ScriptFieldsValue = selector?.Invoke(new FluentDescriptorDictionary()); + return Self; + } + + public MultisearchBodyDescriptor SearchAfter(ICollection? searchAfter) + { + SearchAfterValue = searchAfter; + return Self; + } + + /// + /// If true, returns sequence number and primary term of the last modification
of each hit. See Optimistic concurrency control.
+ ///
+ public MultisearchBodyDescriptor SeqNoPrimaryTerm(bool? seqNoPrimaryTerm = true) + { + SeqNoPrimaryTermValue = seqNoPrimaryTerm; + return Self; + } + + /// + /// The number of hits to return. By default, you cannot page through more
than 10,000 hits using the from and size parameters. To page through more
hits, use the search_after parameter.
+ ///
+ public MultisearchBodyDescriptor Size(int? size) + { + SizeValue = size; + return Self; + } + + public MultisearchBodyDescriptor Sort(ICollection? sort) + { + SortDescriptor = null; + SortDescriptorAction = null; + SortDescriptorActions = null; + SortValue = sort; + return Self; + } + + public MultisearchBodyDescriptor Sort(Elastic.Clients.Elasticsearch.SortOptionsDescriptor descriptor) + { + SortValue = null; + SortDescriptorAction = null; + SortDescriptorActions = null; + SortDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Sort(Action> configure) + { + SortValue = null; + SortDescriptor = null; + SortDescriptorActions = null; + SortDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Sort(params Action>[] configure) + { + SortValue = null; + SortDescriptor = null; + SortDescriptorAction = null; + SortDescriptorActions = configure; + return Self; + } + + /// + /// Indicates which source fields are returned for matching documents. These
fields are returned in the hits._source property of the search response.
+ ///
+ public MultisearchBodyDescriptor Source(Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? source) + { + SourceValue = source; + return Self; + } + + /// + /// Stats groups to associate with the search. Each group maintains a statistics
aggregation for its associated searches. You can retrieve these stats using
the indices stats API.
+ ///
+ public MultisearchBodyDescriptor Stats(ICollection? stats) + { + StatsValue = stats; + return Self; + } + + /// + /// List of stored fields to return as part of a hit. If no fields are specified,
no stored fields are included in the response. If this field is specified, the _source
parameter defaults to false. You can pass _source: true to return both source fields
and stored fields in the search response.
+ ///
+ public MultisearchBodyDescriptor StoredFields(Elastic.Clients.Elasticsearch.Fields? storedFields) + { + StoredFieldsValue = storedFields; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Elastic.Clients.Elasticsearch.Core.Search.Suggester? suggest) + { + SuggestDescriptor = null; + SuggestDescriptorAction = null; + SuggestValue = suggest; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Elastic.Clients.Elasticsearch.Core.Search.SuggesterDescriptor descriptor) + { + SuggestValue = null; + SuggestDescriptorAction = null; + SuggestDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Action> configure) + { + SuggestValue = null; + SuggestDescriptor = null; + SuggestDescriptorAction = configure; + return Self; + } + + /// + /// Maximum number of documents to collect for each shard. If a query reaches this
limit, Elasticsearch terminates the query early. Elasticsearch collects documents
before sorting. Defaults to 0, which does not terminate query execution early.
+ ///
+ public MultisearchBodyDescriptor TerminateAfter(long? terminateAfter) + { + TerminateAfterValue = terminateAfter; + return Self; + } + + /// + /// Specifies the period of time to wait for a response from each shard. If no response
is received before the timeout expires, the request fails and returns an error.
Defaults to no timeout.
+ ///
+ public MultisearchBodyDescriptor Timeout(string? timeout) + { + TimeoutValue = timeout; + return Self; + } + + /// + /// If true, calculate and return document scores, even if the scores are not used for sorting. + /// + public MultisearchBodyDescriptor TrackScores(bool? trackScores = true) + { + TrackScoresValue = trackScores; + return Self; + } + + /// + /// Number of hits matching the query to count accurately. If true, the exact
number of hits is returned at the cost of some performance. If false, the
response does not include the total number of hits matching the query.
Defaults to 10,000 hits.
+ ///
+ public MultisearchBodyDescriptor TrackTotalHits(Elastic.Clients.Elasticsearch.Core.Search.TrackHits? trackTotalHits) + { + TrackTotalHitsValue = trackTotalHits; + return Self; + } + + /// + /// If true, returns document version as part of a hit. + /// + public MultisearchBodyDescriptor Version(bool? version = true) + { + VersionValue = version; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + if (CollapseDescriptor is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, CollapseDescriptor, options); + } + else if (CollapseDescriptorAction is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.FieldCollapseDescriptor(CollapseDescriptorAction), options); + } + else if (CollapseValue is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, CollapseValue, options); + } + + if (DocvalueFieldsDescriptor is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, DocvalueFieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (DocvalueFieldsDescriptorAction is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor(DocvalueFieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (DocvalueFieldsDescriptorActions is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + foreach (var action in DocvalueFieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (DocvalueFieldsValue is not null) + { + writer.WritePropertyName("docvalue_fields"); + JsonSerializer.Serialize(writer, DocvalueFieldsValue, options); + } + + if (ExplainValue.HasValue) + { + writer.WritePropertyName("explain"); + writer.WriteBooleanValue(ExplainValue.Value); + } + + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + + if (FieldsDescriptor is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, FieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (FieldsDescriptorAction is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor(FieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (FieldsDescriptorActions is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + foreach (var action in FieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (FieldsValue is not null) + { + writer.WritePropertyName("fields"); + JsonSerializer.Serialize(writer, FieldsValue, options); + } + + if (FromValue.HasValue) + { + writer.WritePropertyName("from"); + writer.WriteNumberValue(FromValue.Value); + } + + if (HighlightDescriptor is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, HighlightDescriptor, options); + } + else if (HighlightDescriptorAction is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.HighlightDescriptor(HighlightDescriptorAction), options); + } + else if (HighlightValue is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, HighlightValue, options); + } + + if (IndicesBoostValue is not null) + { + writer.WritePropertyName("indices_boost"); + JsonSerializer.Serialize(writer, IndicesBoostValue, options); + } + + if (KnnDescriptor is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, KnnDescriptor, options); + } + else if (KnnDescriptorAction is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.KnnQueryDescriptor(KnnDescriptorAction), options); + } + else if (KnnDescriptorActions is not null) + { + writer.WritePropertyName("knn"); + if (KnnDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in KnnDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.KnnQueryDescriptor(action), options); + } + + if (KnnDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (KnnValue is not null) + { + writer.WritePropertyName("knn"); + SingleOrManySerializationHelper.Serialize(KnnValue, writer, options); + } + + if (MinScoreValue.HasValue) + { + writer.WritePropertyName("min_score"); + writer.WriteNumberValue(MinScoreValue.Value); + } + + if (PitDescriptor is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, PitDescriptor, options); + } + else if (PitDescriptorAction is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReferenceDescriptor(PitDescriptorAction), options); + } + else if (PitValue is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, PitValue, options); + } + + if (PostFilterDescriptor is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, PostFilterDescriptor, options); + } + else if (PostFilterDescriptorAction is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor(PostFilterDescriptorAction), options); + } + else if (PostFilterValue is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, PostFilterValue, options); + } + + if (ProfileValue.HasValue) + { + writer.WritePropertyName("profile"); + writer.WriteBooleanValue(ProfileValue.Value); + } + + if (QueryDescriptor is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, QueryDescriptor, options); + } + else if (QueryDescriptorAction is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor(QueryDescriptorAction), options); + } + else if (QueryValue is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, QueryValue, options); + } + + if (RescoreDescriptor is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, RescoreDescriptor, options); + } + else if (RescoreDescriptorAction is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.RescoreDescriptor(RescoreDescriptorAction), options); + } + else if (RescoreDescriptorActions is not null) + { + writer.WritePropertyName("rescore"); + if (RescoreDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in RescoreDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.RescoreDescriptor(action), options); + } + + if (RescoreDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (RescoreValue is not null) + { + writer.WritePropertyName("rescore"); + SingleOrManySerializationHelper.Serialize(RescoreValue, writer, options); + } + + if (RuntimeMappingsValue is not null) + { + writer.WritePropertyName("runtime_mappings"); + JsonSerializer.Serialize(writer, RuntimeMappingsValue, options); + } + + if (ScriptFieldsValue is not null) + { + writer.WritePropertyName("script_fields"); + JsonSerializer.Serialize(writer, ScriptFieldsValue, options); + } + + if (SearchAfterValue is not null) + { + writer.WritePropertyName("search_after"); + JsonSerializer.Serialize(writer, SearchAfterValue, options); + } + + if (SeqNoPrimaryTermValue.HasValue) + { + writer.WritePropertyName("seq_no_primary_term"); + writer.WriteBooleanValue(SeqNoPrimaryTermValue.Value); + } + + if (SizeValue.HasValue) + { + writer.WritePropertyName("size"); + writer.WriteNumberValue(SizeValue.Value); + } + + if (SortDescriptor is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, SortDescriptor, options); + } + else if (SortDescriptorAction is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.SortOptionsDescriptor(SortDescriptorAction), options); + } + else if (SortDescriptorActions is not null) + { + writer.WritePropertyName("sort"); + if (SortDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in SortDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.SortOptionsDescriptor(action), options); + } + + if (SortDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (SortValue is not null) + { + writer.WritePropertyName("sort"); + SingleOrManySerializationHelper.Serialize(SortValue, writer, options); + } + + if (SourceValue is not null) + { + writer.WritePropertyName("_source"); + JsonSerializer.Serialize(writer, SourceValue, options); + } + + if (StatsValue is not null) + { + writer.WritePropertyName("stats"); + JsonSerializer.Serialize(writer, StatsValue, options); + } + + if (StoredFieldsValue is not null) + { + writer.WritePropertyName("stored_fields"); + JsonSerializer.Serialize(writer, StoredFieldsValue, options); + } + + if (SuggestDescriptor is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, SuggestDescriptor, options); + } + else if (SuggestDescriptorAction is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.SuggesterDescriptor(SuggestDescriptorAction), options); + } + else if (SuggestValue is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, SuggestValue, options); + } + + if (TerminateAfterValue.HasValue) + { + writer.WritePropertyName("terminate_after"); + writer.WriteNumberValue(TerminateAfterValue.Value); + } + + if (!string.IsNullOrEmpty(TimeoutValue)) + { + writer.WritePropertyName("timeout"); + writer.WriteStringValue(TimeoutValue); + } + + if (TrackScoresValue.HasValue) + { + writer.WritePropertyName("track_scores"); + writer.WriteBooleanValue(TrackScoresValue.Value); + } + + if (TrackTotalHitsValue is not null) + { + writer.WritePropertyName("track_total_hits"); + JsonSerializer.Serialize(writer, TrackTotalHitsValue, options); + } + + if (VersionValue.HasValue) + { + writer.WritePropertyName("version"); + writer.WriteBooleanValue(VersionValue.Value); + } + + writer.WriteEndObject(); + } +} + +public sealed partial class MultisearchBodyDescriptor : SerializableDescriptor +{ + internal MultisearchBodyDescriptor(Action configure) => configure.Invoke(this); + + public MultisearchBodyDescriptor() : base() + { + } + + private IDictionary AggregationsValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? CollapseValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.FieldCollapseDescriptor CollapseDescriptor { get; set; } + private Action CollapseDescriptorAction { get; set; } + private ICollection? DocvalueFieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor DocvalueFieldsDescriptor { get; set; } + private Action DocvalueFieldsDescriptorAction { get; set; } + private Action[] DocvalueFieldsDescriptorActions { get; set; } + private bool? ExplainValue { get; set; } + private IDictionary? ExtValue { get; set; } + private ICollection? FieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor FieldsDescriptor { get; set; } + private Action FieldsDescriptorAction { get; set; } + private Action[] FieldsDescriptorActions { get; set; } + private int? FromValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.Highlight? HighlightValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.HighlightDescriptor HighlightDescriptor { get; set; } + private Action HighlightDescriptorAction { get; set; } + private ICollection>? IndicesBoostValue { get; set; } + private ICollection? KnnValue { get; set; } + private Elastic.Clients.Elasticsearch.KnnQueryDescriptor KnnDescriptor { get; set; } + private Action KnnDescriptorAction { get; set; } + private Action[] KnnDescriptorActions { get; set; } + private double? MinScoreValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? PitValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReferenceDescriptor PitDescriptor { get; set; } + private Action PitDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilterValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor PostFilterDescriptor { get; set; } + private Action PostFilterDescriptorAction { get; set; } + private bool? ProfileValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.Query? QueryValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor QueryDescriptor { get; set; } + private Action QueryDescriptorAction { get; set; } + private ICollection? RescoreValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.RescoreDescriptor RescoreDescriptor { get; set; } + private Action RescoreDescriptorAction { get; set; } + private Action[] RescoreDescriptorActions { get; set; } + private IDictionary RuntimeMappingsValue { get; set; } + private IDictionary ScriptFieldsValue { get; set; } + private ICollection? SearchAfterValue { get; set; } + private bool? SeqNoPrimaryTermValue { get; set; } + private int? SizeValue { get; set; } + private ICollection? SortValue { get; set; } + private Elastic.Clients.Elasticsearch.SortOptionsDescriptor SortDescriptor { get; set; } + private Action SortDescriptorAction { get; set; } + private Action[] SortDescriptorActions { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? SourceValue { get; set; } + private ICollection? StatsValue { get; set; } + private Elastic.Clients.Elasticsearch.Fields? StoredFieldsValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.Suggester? SuggestValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.SuggesterDescriptor SuggestDescriptor { get; set; } + private Action SuggestDescriptorAction { get; set; } + private long? TerminateAfterValue { get; set; } + private string? TimeoutValue { get; set; } + private bool? TrackScoresValue { get; set; } + private Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHitsValue { get; set; } + private bool? VersionValue { get; set; } + + public MultisearchBodyDescriptor Aggregations(Func, FluentDescriptorDictionary> selector) + { + AggregationsValue = selector?.Invoke(new FluentDescriptorDictionary()); + return Self; + } + + public MultisearchBodyDescriptor Collapse(Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? collapse) + { + CollapseDescriptor = null; + CollapseDescriptorAction = null; + CollapseValue = collapse; + return Self; + } + + public MultisearchBodyDescriptor Collapse(Elastic.Clients.Elasticsearch.Core.Search.FieldCollapseDescriptor descriptor) + { + CollapseValue = null; + CollapseDescriptorAction = null; + CollapseDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Collapse(Action configure) + { + CollapseValue = null; + CollapseDescriptor = null; + CollapseDescriptorAction = configure; + return Self; + } + + /// + /// Array of wildcard (*) patterns. The request returns doc values for field
names matching these patterns in the hits.fields property of the response.
+ ///
+ public MultisearchBodyDescriptor DocvalueFields(ICollection? docvalueFields) + { + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsValue = docvalueFields; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor descriptor) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(Action configure) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorActions = null; + DocvalueFieldsDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor DocvalueFields(params Action[] configure) + { + DocvalueFieldsValue = null; + DocvalueFieldsDescriptor = null; + DocvalueFieldsDescriptorAction = null; + DocvalueFieldsDescriptorActions = configure; + return Self; + } + + /// + /// If true, returns detailed information about score computation as part of a hit. + /// + public MultisearchBodyDescriptor Explain(bool? explain = true) + { + ExplainValue = explain; + return Self; + } + + /// + /// Configuration of search extensions defined by Elasticsearch plugins. + /// + public MultisearchBodyDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + /// + /// Array of wildcard (*) patterns. The request returns values for field names
matching these patterns in the hits.fields property of the response.
+ ///
+ public MultisearchBodyDescriptor Fields(ICollection? fields) + { + FieldsDescriptor = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = null; + FieldsValue = fields; + return Self; + } + + public MultisearchBodyDescriptor Fields(Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor descriptor) + { + FieldsValue = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = null; + FieldsDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Fields(Action configure) + { + FieldsValue = null; + FieldsDescriptor = null; + FieldsDescriptorActions = null; + FieldsDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Fields(params Action[] configure) + { + FieldsValue = null; + FieldsDescriptor = null; + FieldsDescriptorAction = null; + FieldsDescriptorActions = configure; + return Self; + } + + /// + /// Starting document offset. By default, you cannot page through more than 10,000
hits using the from and size parameters. To page through more hits, use the
search_after parameter.
+ ///
+ public MultisearchBodyDescriptor From(int? from) + { + FromValue = from; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Elastic.Clients.Elasticsearch.Core.Search.Highlight? highlight) + { + HighlightDescriptor = null; + HighlightDescriptorAction = null; + HighlightValue = highlight; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Elastic.Clients.Elasticsearch.Core.Search.HighlightDescriptor descriptor) + { + HighlightValue = null; + HighlightDescriptorAction = null; + HighlightDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Highlight(Action configure) + { + HighlightValue = null; + HighlightDescriptor = null; + HighlightDescriptorAction = configure; + return Self; + } + + /// + /// Boosts the _score of documents from specified indices. + /// + public MultisearchBodyDescriptor IndicesBoost(ICollection>? indicesBoost) + { + IndicesBoostValue = indicesBoost; + return Self; + } + + /// + /// Defines the approximate kNN search to run. + /// + public MultisearchBodyDescriptor Knn(ICollection? knn) + { + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = null; + KnnValue = knn; + return Self; + } + + public MultisearchBodyDescriptor Knn(Elastic.Clients.Elasticsearch.KnnQueryDescriptor descriptor) + { + KnnValue = null; + KnnDescriptorAction = null; + KnnDescriptorActions = null; + KnnDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Knn(Action configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorActions = null; + KnnDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Knn(params Action[] configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = configure; + return Self; + } + + /// + /// Minimum _score for matching documents. Documents with a lower _score are
not included in the search results.
+ ///
+ public MultisearchBodyDescriptor MinScore(double? minScore) + { + MinScoreValue = minScore; + return Self; + } + + /// + /// Limits the search to a point in time (PIT). If you provide a PIT, you
cannot specify an in the request path.
+ ///
+ public MultisearchBodyDescriptor Pit(Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? pit) + { + PitDescriptor = null; + PitDescriptorAction = null; + PitValue = pit; + return Self; + } + + public MultisearchBodyDescriptor Pit(Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReferenceDescriptor descriptor) + { + PitValue = null; + PitDescriptorAction = null; + PitDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Pit(Action configure) + { + PitValue = null; + PitDescriptor = null; + PitDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Elastic.Clients.Elasticsearch.QueryDsl.Query? postFilter) + { + PostFilterDescriptor = null; + PostFilterDescriptorAction = null; + PostFilterValue = postFilter; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor descriptor) + { + PostFilterValue = null; + PostFilterDescriptorAction = null; + PostFilterDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor PostFilter(Action configure) + { + PostFilterValue = null; + PostFilterDescriptor = null; + PostFilterDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Profile(bool? profile = true) + { + ProfileValue = profile; + return Self; + } + + /// + /// Defines the search definition using the Query DSL. + /// + public MultisearchBodyDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.Query? query) + { + QueryDescriptor = null; + QueryDescriptorAction = null; + QueryValue = query; + return Self; + } + + public MultisearchBodyDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor descriptor) + { + QueryValue = null; + QueryDescriptorAction = null; + QueryDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Query(Action configure) + { + QueryValue = null; + QueryDescriptor = null; + QueryDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Rescore(ICollection? rescore) + { + RescoreDescriptor = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = null; + RescoreValue = rescore; + return Self; + } + + public MultisearchBodyDescriptor Rescore(Elastic.Clients.Elasticsearch.Core.Search.RescoreDescriptor descriptor) + { + RescoreValue = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = null; + RescoreDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Rescore(Action configure) + { + RescoreValue = null; + RescoreDescriptor = null; + RescoreDescriptorActions = null; + RescoreDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Rescore(params Action[] configure) + { + RescoreValue = null; + RescoreDescriptor = null; + RescoreDescriptorAction = null; + RescoreDescriptorActions = configure; + return Self; + } + + /// + /// Defines one or more runtime fields in the search request. These fields take
precedence over mapped fields with the same name.
+ ///
+ public MultisearchBodyDescriptor RuntimeMappings(Func, FluentDescriptorDictionary> selector) + { + RuntimeMappingsValue = selector?.Invoke(new FluentDescriptorDictionary()); + return Self; + } + + /// + /// Retrieve a script evaluation (based on different fields) for each hit. + /// + public MultisearchBodyDescriptor ScriptFields(Func, FluentDescriptorDictionary> selector) + { + ScriptFieldsValue = selector?.Invoke(new FluentDescriptorDictionary()); + return Self; + } + + public MultisearchBodyDescriptor SearchAfter(ICollection? searchAfter) + { + SearchAfterValue = searchAfter; + return Self; + } + + /// + /// If true, returns sequence number and primary term of the last modification
of each hit. See Optimistic concurrency control.
+ ///
+ public MultisearchBodyDescriptor SeqNoPrimaryTerm(bool? seqNoPrimaryTerm = true) + { + SeqNoPrimaryTermValue = seqNoPrimaryTerm; + return Self; + } + + /// + /// The number of hits to return. By default, you cannot page through more
than 10,000 hits using the from and size parameters. To page through more
hits, use the search_after parameter.
+ ///
+ public MultisearchBodyDescriptor Size(int? size) + { + SizeValue = size; + return Self; + } + + public MultisearchBodyDescriptor Sort(ICollection? sort) + { + SortDescriptor = null; + SortDescriptorAction = null; + SortDescriptorActions = null; + SortValue = sort; + return Self; + } + + public MultisearchBodyDescriptor Sort(Elastic.Clients.Elasticsearch.SortOptionsDescriptor descriptor) + { + SortValue = null; + SortDescriptorAction = null; + SortDescriptorActions = null; + SortDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Sort(Action configure) + { + SortValue = null; + SortDescriptor = null; + SortDescriptorActions = null; + SortDescriptorAction = configure; + return Self; + } + + public MultisearchBodyDescriptor Sort(params Action[] configure) + { + SortValue = null; + SortDescriptor = null; + SortDescriptorAction = null; + SortDescriptorActions = configure; + return Self; + } + + /// + /// Indicates which source fields are returned for matching documents. These
fields are returned in the hits._source property of the search response.
+ ///
+ public MultisearchBodyDescriptor Source(Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? source) + { + SourceValue = source; + return Self; + } + + /// + /// Stats groups to associate with the search. Each group maintains a statistics
aggregation for its associated searches. You can retrieve these stats using
the indices stats API.
+ ///
+ public MultisearchBodyDescriptor Stats(ICollection? stats) + { + StatsValue = stats; + return Self; + } + + /// + /// List of stored fields to return as part of a hit. If no fields are specified,
no stored fields are included in the response. If this field is specified, the _source
parameter defaults to false. You can pass _source: true to return both source fields
and stored fields in the search response.
+ ///
+ public MultisearchBodyDescriptor StoredFields(Elastic.Clients.Elasticsearch.Fields? storedFields) + { + StoredFieldsValue = storedFields; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Elastic.Clients.Elasticsearch.Core.Search.Suggester? suggest) + { + SuggestDescriptor = null; + SuggestDescriptorAction = null; + SuggestValue = suggest; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Elastic.Clients.Elasticsearch.Core.Search.SuggesterDescriptor descriptor) + { + SuggestValue = null; + SuggestDescriptorAction = null; + SuggestDescriptor = descriptor; + return Self; + } + + public MultisearchBodyDescriptor Suggest(Action configure) + { + SuggestValue = null; + SuggestDescriptor = null; + SuggestDescriptorAction = configure; + return Self; + } + + /// + /// Maximum number of documents to collect for each shard. If a query reaches this
limit, Elasticsearch terminates the query early. Elasticsearch collects documents
before sorting. Defaults to 0, which does not terminate query execution early.
+ ///
+ public MultisearchBodyDescriptor TerminateAfter(long? terminateAfter) + { + TerminateAfterValue = terminateAfter; + return Self; + } + + /// + /// Specifies the period of time to wait for a response from each shard. If no response
is received before the timeout expires, the request fails and returns an error.
Defaults to no timeout.
+ ///
+ public MultisearchBodyDescriptor Timeout(string? timeout) + { + TimeoutValue = timeout; + return Self; + } + + /// + /// If true, calculate and return document scores, even if the scores are not used for sorting. + /// + public MultisearchBodyDescriptor TrackScores(bool? trackScores = true) + { + TrackScoresValue = trackScores; + return Self; + } + + /// + /// Number of hits matching the query to count accurately. If true, the exact
number of hits is returned at the cost of some performance. If false, the
response does not include the total number of hits matching the query.
Defaults to 10,000 hits.
+ ///
+ public MultisearchBodyDescriptor TrackTotalHits(Elastic.Clients.Elasticsearch.Core.Search.TrackHits? trackTotalHits) + { + TrackTotalHitsValue = trackTotalHits; + return Self; + } + + /// + /// If true, returns document version as part of a hit. + /// + public MultisearchBodyDescriptor Version(bool? version = true) + { + VersionValue = version; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (AggregationsValue is not null) + { + writer.WritePropertyName("aggregations"); + JsonSerializer.Serialize(writer, AggregationsValue, options); + } + + if (CollapseDescriptor is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, CollapseDescriptor, options); + } + else if (CollapseDescriptorAction is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.FieldCollapseDescriptor(CollapseDescriptorAction), options); + } + else if (CollapseValue is not null) + { + writer.WritePropertyName("collapse"); + JsonSerializer.Serialize(writer, CollapseValue, options); + } + + if (DocvalueFieldsDescriptor is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, DocvalueFieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (DocvalueFieldsDescriptorAction is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor(DocvalueFieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (DocvalueFieldsDescriptorActions is not null) + { + writer.WritePropertyName("docvalue_fields"); + writer.WriteStartArray(); + foreach (var action in DocvalueFieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (DocvalueFieldsValue is not null) + { + writer.WritePropertyName("docvalue_fields"); + JsonSerializer.Serialize(writer, DocvalueFieldsValue, options); + } + + if (ExplainValue.HasValue) + { + writer.WritePropertyName("explain"); + writer.WriteBooleanValue(ExplainValue.Value); + } + + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + + if (FieldsDescriptor is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, FieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (FieldsDescriptorAction is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor(FieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (FieldsDescriptorActions is not null) + { + writer.WritePropertyName("fields"); + writer.WriteStartArray(); + foreach (var action in FieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormatDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (FieldsValue is not null) + { + writer.WritePropertyName("fields"); + JsonSerializer.Serialize(writer, FieldsValue, options); + } + + if (FromValue.HasValue) + { + writer.WritePropertyName("from"); + writer.WriteNumberValue(FromValue.Value); + } + + if (HighlightDescriptor is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, HighlightDescriptor, options); + } + else if (HighlightDescriptorAction is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.HighlightDescriptor(HighlightDescriptorAction), options); + } + else if (HighlightValue is not null) + { + writer.WritePropertyName("highlight"); + JsonSerializer.Serialize(writer, HighlightValue, options); + } + + if (IndicesBoostValue is not null) + { + writer.WritePropertyName("indices_boost"); + JsonSerializer.Serialize(writer, IndicesBoostValue, options); + } + + if (KnnDescriptor is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, KnnDescriptor, options); + } + else if (KnnDescriptorAction is not null) + { + writer.WritePropertyName("knn"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.KnnQueryDescriptor(KnnDescriptorAction), options); + } + else if (KnnDescriptorActions is not null) + { + writer.WritePropertyName("knn"); + if (KnnDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in KnnDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.KnnQueryDescriptor(action), options); + } + + if (KnnDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (KnnValue is not null) + { + writer.WritePropertyName("knn"); + SingleOrManySerializationHelper.Serialize(KnnValue, writer, options); + } + + if (MinScoreValue.HasValue) + { + writer.WritePropertyName("min_score"); + writer.WriteNumberValue(MinScoreValue.Value); + } + + if (PitDescriptor is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, PitDescriptor, options); + } + else if (PitDescriptorAction is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReferenceDescriptor(PitDescriptorAction), options); + } + else if (PitValue is not null) + { + writer.WritePropertyName("pit"); + JsonSerializer.Serialize(writer, PitValue, options); + } + + if (PostFilterDescriptor is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, PostFilterDescriptor, options); + } + else if (PostFilterDescriptorAction is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor(PostFilterDescriptorAction), options); + } + else if (PostFilterValue is not null) + { + writer.WritePropertyName("post_filter"); + JsonSerializer.Serialize(writer, PostFilterValue, options); + } + + if (ProfileValue.HasValue) + { + writer.WritePropertyName("profile"); + writer.WriteBooleanValue(ProfileValue.Value); + } + + if (QueryDescriptor is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, QueryDescriptor, options); + } + else if (QueryDescriptorAction is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor(QueryDescriptorAction), options); + } + else if (QueryValue is not null) + { + writer.WritePropertyName("query"); + JsonSerializer.Serialize(writer, QueryValue, options); + } + + if (RescoreDescriptor is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, RescoreDescriptor, options); + } + else if (RescoreDescriptorAction is not null) + { + writer.WritePropertyName("rescore"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.RescoreDescriptor(RescoreDescriptorAction), options); + } + else if (RescoreDescriptorActions is not null) + { + writer.WritePropertyName("rescore"); + if (RescoreDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in RescoreDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.RescoreDescriptor(action), options); + } + + if (RescoreDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (RescoreValue is not null) + { + writer.WritePropertyName("rescore"); + SingleOrManySerializationHelper.Serialize(RescoreValue, writer, options); + } + + if (RuntimeMappingsValue is not null) + { + writer.WritePropertyName("runtime_mappings"); + JsonSerializer.Serialize(writer, RuntimeMappingsValue, options); + } + + if (ScriptFieldsValue is not null) + { + writer.WritePropertyName("script_fields"); + JsonSerializer.Serialize(writer, ScriptFieldsValue, options); + } + + if (SearchAfterValue is not null) + { + writer.WritePropertyName("search_after"); + JsonSerializer.Serialize(writer, SearchAfterValue, options); + } + + if (SeqNoPrimaryTermValue.HasValue) + { + writer.WritePropertyName("seq_no_primary_term"); + writer.WriteBooleanValue(SeqNoPrimaryTermValue.Value); + } + + if (SizeValue.HasValue) + { + writer.WritePropertyName("size"); + writer.WriteNumberValue(SizeValue.Value); + } + + if (SortDescriptor is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, SortDescriptor, options); + } + else if (SortDescriptorAction is not null) + { + writer.WritePropertyName("sort"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.SortOptionsDescriptor(SortDescriptorAction), options); + } + else if (SortDescriptorActions is not null) + { + writer.WritePropertyName("sort"); + if (SortDescriptorActions.Length != 1) + writer.WriteStartArray(); + foreach (var action in SortDescriptorActions) + { + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.SortOptionsDescriptor(action), options); + } + + if (SortDescriptorActions.Length != 1) + writer.WriteEndArray(); + } + else if (SortValue is not null) + { + writer.WritePropertyName("sort"); + SingleOrManySerializationHelper.Serialize(SortValue, writer, options); + } + + if (SourceValue is not null) + { + writer.WritePropertyName("_source"); + JsonSerializer.Serialize(writer, SourceValue, options); + } + + if (StatsValue is not null) + { + writer.WritePropertyName("stats"); + JsonSerializer.Serialize(writer, StatsValue, options); + } + + if (StoredFieldsValue is not null) + { + writer.WritePropertyName("stored_fields"); + JsonSerializer.Serialize(writer, StoredFieldsValue, options); + } + + if (SuggestDescriptor is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, SuggestDescriptor, options); + } + else if (SuggestDescriptorAction is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Core.Search.SuggesterDescriptor(SuggestDescriptorAction), options); + } + else if (SuggestValue is not null) + { + writer.WritePropertyName("suggest"); + JsonSerializer.Serialize(writer, SuggestValue, options); + } + + if (TerminateAfterValue.HasValue) + { + writer.WritePropertyName("terminate_after"); + writer.WriteNumberValue(TerminateAfterValue.Value); + } + + if (!string.IsNullOrEmpty(TimeoutValue)) + { + writer.WritePropertyName("timeout"); + writer.WriteStringValue(TimeoutValue); + } + + if (TrackScoresValue.HasValue) + { + writer.WritePropertyName("track_scores"); + writer.WriteBooleanValue(TrackScoresValue.Value); + } + + if (TrackTotalHitsValue is not null) + { + writer.WritePropertyName("track_total_hits"); + JsonSerializer.Serialize(writer, TrackTotalHitsValue, options); + } + + if (VersionValue.HasValue) + { + writer.WritePropertyName("version"); + writer.WriteBooleanValue(VersionValue.Value); + } + + writer.WriteEndObject(); + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs index b36d01f74fd..07fb9e14616 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs @@ -33,26 +33,188 @@ namespace Elastic.Clients.Elasticsearch.Core.MSearch; public sealed partial class MultisearchHeader { [JsonInclude, JsonPropertyName("allow_no_indices")] - public bool? AllowNoIndices { get; init; } + public bool? AllowNoIndices { get; set; } [JsonInclude, JsonPropertyName("allow_partial_search_results")] - public bool? AllowPartialSearchResults { get; init; } + public bool? AllowPartialSearchResults { get; set; } [JsonInclude, JsonPropertyName("ccs_minimize_roundtrips")] - public bool? CcsMinimizeRoundtrips { get; init; } + public bool? CcsMinimizeRoundtrips { get; set; } [JsonInclude, JsonPropertyName("expand_wildcards")] [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.ExpandWildcard))] - public IReadOnlyCollection? ExpandWildcards { get; init; } + public ICollection? ExpandWildcards { get; set; } [JsonInclude, JsonPropertyName("ignore_throttled")] - public bool? IgnoreThrottled { get; init; } + public bool? IgnoreThrottled { get; set; } [JsonInclude, JsonPropertyName("ignore_unavailable")] - public bool? IgnoreUnavailable { get; init; } + public bool? IgnoreUnavailable { get; set; } [JsonInclude, JsonPropertyName("index")] - public Elastic.Clients.Elasticsearch.Indices? Indices { get; init; } + public Elastic.Clients.Elasticsearch.Indices? Indices { get; set; } [JsonInclude, JsonPropertyName("preference")] - public string? Preference { get; init; } + public string? Preference { get; set; } [JsonInclude, JsonPropertyName("request_cache")] - public bool? RequestCache { get; init; } + public bool? RequestCache { get; set; } [JsonInclude, JsonPropertyName("routing")] - public Elastic.Clients.Elasticsearch.Routing? Routing { get; init; } + public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } [JsonInclude, JsonPropertyName("search_type")] - public Elastic.Clients.Elasticsearch.SearchType? SearchType { get; init; } + public Elastic.Clients.Elasticsearch.SearchType? SearchType { get; set; } +} + +/// +/// Contains parameters used to limit or change the subsequent search body request. +/// +public sealed partial class MultisearchHeaderDescriptor : SerializableDescriptor +{ + internal MultisearchHeaderDescriptor(Action configure) => configure.Invoke(this); + + public MultisearchHeaderDescriptor() : base() + { + } + + private bool? AllowNoIndicesValue { get; set; } + private bool? AllowPartialSearchResultsValue { get; set; } + private bool? CcsMinimizeRoundtripsValue { get; set; } + private ICollection? ExpandWildcardsValue { get; set; } + private bool? IgnoreThrottledValue { get; set; } + private bool? IgnoreUnavailableValue { get; set; } + private Elastic.Clients.Elasticsearch.Indices? IndicesValue { get; set; } + private string? PreferenceValue { get; set; } + private bool? RequestCacheValue { get; set; } + private Elastic.Clients.Elasticsearch.Routing? RoutingValue { get; set; } + private Elastic.Clients.Elasticsearch.SearchType? SearchTypeValue { get; set; } + + public MultisearchHeaderDescriptor AllowNoIndices(bool? allowNoIndices = true) + { + AllowNoIndicesValue = allowNoIndices; + return Self; + } + + public MultisearchHeaderDescriptor AllowPartialSearchResults(bool? allowPartialSearchResults = true) + { + AllowPartialSearchResultsValue = allowPartialSearchResults; + return Self; + } + + public MultisearchHeaderDescriptor CcsMinimizeRoundtrips(bool? ccsMinimizeRoundtrips = true) + { + CcsMinimizeRoundtripsValue = ccsMinimizeRoundtrips; + return Self; + } + + public MultisearchHeaderDescriptor ExpandWildcards(ICollection? expandWildcards) + { + ExpandWildcardsValue = expandWildcards; + return Self; + } + + public MultisearchHeaderDescriptor IgnoreThrottled(bool? ignoreThrottled = true) + { + IgnoreThrottledValue = ignoreThrottled; + return Self; + } + + public MultisearchHeaderDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) + { + IgnoreUnavailableValue = ignoreUnavailable; + return Self; + } + + public MultisearchHeaderDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? indices) + { + IndicesValue = indices; + return Self; + } + + public MultisearchHeaderDescriptor Preference(string? preference) + { + PreferenceValue = preference; + return Self; + } + + public MultisearchHeaderDescriptor RequestCache(bool? requestCache = true) + { + RequestCacheValue = requestCache; + return Self; + } + + public MultisearchHeaderDescriptor Routing(Elastic.Clients.Elasticsearch.Routing? routing) + { + RoutingValue = routing; + return Self; + } + + public MultisearchHeaderDescriptor SearchType(Elastic.Clients.Elasticsearch.SearchType? searchType) + { + SearchTypeValue = searchType; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (AllowNoIndicesValue.HasValue) + { + writer.WritePropertyName("allow_no_indices"); + writer.WriteBooleanValue(AllowNoIndicesValue.Value); + } + + if (AllowPartialSearchResultsValue.HasValue) + { + writer.WritePropertyName("allow_partial_search_results"); + writer.WriteBooleanValue(AllowPartialSearchResultsValue.Value); + } + + if (CcsMinimizeRoundtripsValue.HasValue) + { + writer.WritePropertyName("ccs_minimize_roundtrips"); + writer.WriteBooleanValue(CcsMinimizeRoundtripsValue.Value); + } + + if (ExpandWildcardsValue is not null) + { + writer.WritePropertyName("expand_wildcards"); + SingleOrManySerializationHelper.Serialize(ExpandWildcardsValue, writer, options); + } + + if (IgnoreThrottledValue.HasValue) + { + writer.WritePropertyName("ignore_throttled"); + writer.WriteBooleanValue(IgnoreThrottledValue.Value); + } + + if (IgnoreUnavailableValue.HasValue) + { + writer.WritePropertyName("ignore_unavailable"); + writer.WriteBooleanValue(IgnoreUnavailableValue.Value); + } + + if (IndicesValue is not null) + { + writer.WritePropertyName("index"); + JsonSerializer.Serialize(writer, IndicesValue, options); + } + + if (!string.IsNullOrEmpty(PreferenceValue)) + { + writer.WritePropertyName("preference"); + writer.WriteStringValue(PreferenceValue); + } + + if (RequestCacheValue.HasValue) + { + writer.WritePropertyName("request_cache"); + writer.WriteBooleanValue(RequestCacheValue.Value); + } + + if (RoutingValue is not null) + { + writer.WritePropertyName("routing"); + JsonSerializer.Serialize(writer, RoutingValue, options); + } + + if (SearchTypeValue is not null) + { + writer.WritePropertyName("search_type"); + JsonSerializer.Serialize(writer, SearchTypeValue, options); + } + + writer.WriteEndObject(); + } } \ No newline at end of file