Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix MultiSearch functionality #8176

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ public SubmitAsyncSearchRequestDescriptor(Elastic.Clients.Elasticsearch.Serverle
{
}

public SubmitAsyncSearchRequestDescriptor() : this(typeof(TDocument))
public SubmitAsyncSearchRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public HealthRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indices?
{
}

public HealthRequestDescriptor() : this(typeof(TDocument))
public HealthRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public CountRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indices?
{
}

public CountRequestDescriptor() : this(typeof(TDocument))
public CountRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public FieldCapsRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indic
{
}

public FieldCapsRequestDescriptor() : this(typeof(TDocument))
public FieldCapsRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public ClearCacheRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indi
{
}

public ClearCacheRequestDescriptor() : this(typeof(TDocument))
public ClearCacheRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public ExistsAliasRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Ind
{
}

public ExistsAliasRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Names name) : this(typeof(TDocument), name)
public ExistsAliasRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Names name) : base(r => r.Required("name", name))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public FlushRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indices?
{
}

public FlushRequestDescriptor() : this(typeof(TDocument))
public FlushRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public ForcemergeRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indi
{
}

public ForcemergeRequestDescriptor() : this(typeof(TDocument))
public ForcemergeRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ public GetAliasRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indice
{
}

public GetAliasRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Names? name) : this(typeof(TDocument), name)
{
}

public GetAliasRequestDescriptor()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ public GetIndicesSettingsRequestDescriptor(Elastic.Clients.Elasticsearch.Serverl
{
}

public GetIndicesSettingsRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Names? name) : this(typeof(TDocument), name)
{
}

public GetIndicesSettingsRequestDescriptor()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public GetMappingRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indi
{
}

public GetMappingRequestDescriptor() : this(typeof(TDocument))
public GetMappingRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ public IndicesStatsRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.In
{
}

public IndicesStatsRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Metrics? metric) : this(typeof(TDocument), metric)
{
}

public IndicesStatsRequestDescriptor()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public RecoveryRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indice
{
}

public RecoveryRequestDescriptor() : this(typeof(TDocument))
public RecoveryRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public RefreshRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indices
{
}

public RefreshRequestDescriptor() : this(typeof(TDocument))
public RefreshRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public SegmentsRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indice
{
}

public SegmentsRequestDescriptor() : this(typeof(TDocument))
public SegmentsRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public ValidateQueryRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.I
{
}

public ValidateQueryRequestDescriptor() : this(typeof(TDocument))
public ValidateQueryRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ async Task IStreamSerializable.SerializeAsync(Stream stream, IElasticsearchClien
/// <summary>
/// <para>Allows to execute several search operations in one request.</para>
/// </summary>
public sealed partial class MultiSearchRequestDescriptor<TDocument> : RequestDescriptor<MultiSearchRequestDescriptor<TDocument>, MultiSearchRequestParameters>
public sealed partial class MultiSearchRequestDescriptor<TDocument> : RequestDescriptor<MultiSearchRequestDescriptor<TDocument>, MultiSearchRequestParameters>, IStreamSerializable
{
internal MultiSearchRequestDescriptor(Action<MultiSearchRequestDescriptor<TDocument>> configure) => configure.Invoke(this);

public MultiSearchRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) : base(r => r.Optional("index", indices))
{
}

public MultiSearchRequestDescriptor() : this(typeof(TDocument))
public MultiSearchRequestDescriptor()
{
}

Expand Down Expand Up @@ -259,6 +259,28 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o

List<Elastic.Clients.Elasticsearch.Serverless.Core.MSearch.SearchRequestItem> _items = new();

void IStreamSerializable.Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
if (_items is null)
return;
foreach (var item in _items)
{
if (item is IStreamSerializable serializable)
serializable.Serialize(stream, settings, formatting);
}
}

async Task IStreamSerializable.SerializeAsync(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
if (_items is null)
return;
foreach (var item in _items)
{
if (item is IStreamSerializable serializable)
await serializable.SerializeAsync(stream, settings, formatting).ConfigureAwait(false);
}
}

public MultiSearchRequestDescriptor<TDocument> AddSearches(Elastic.Clients.Elasticsearch.Serverless.Core.MSearch.SearchRequestItem searches)
{
_items.Add(searches);
Expand All @@ -269,7 +291,7 @@ public MultiSearchRequestDescriptor<TDocument> AddSearches(Elastic.Clients.Elast
/// <summary>
/// <para>Allows to execute several search operations in one request.</para>
/// </summary>
public sealed partial class MultiSearchRequestDescriptor : RequestDescriptor<MultiSearchRequestDescriptor, MultiSearchRequestParameters>
public sealed partial class MultiSearchRequestDescriptor : RequestDescriptor<MultiSearchRequestDescriptor, MultiSearchRequestParameters>, IStreamSerializable
{
internal MultiSearchRequestDescriptor(Action<MultiSearchRequestDescriptor> configure) => configure.Invoke(this);

Expand Down Expand Up @@ -314,6 +336,28 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o

List<Elastic.Clients.Elasticsearch.Serverless.Core.MSearch.SearchRequestItem> _items = new();

void IStreamSerializable.Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
if (_items is null)
return;
foreach (var item in _items)
{
if (item is IStreamSerializable serializable)
serializable.Serialize(stream, settings, formatting);
}
}

async Task IStreamSerializable.SerializeAsync(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
if (_items is null)
return;
foreach (var item in _items)
{
if (item is IStreamSerializable serializable)
await serializable.SerializeAsync(stream, settings, formatting).ConfigureAwait(false);
}
}

public MultiSearchRequestDescriptor AddSearches(Elastic.Clients.Elasticsearch.Serverless.Core.MSearch.SearchRequestItem searches)
{
_items.Add(searches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ async Task IStreamSerializable.SerializeAsync(Stream stream, IElasticsearchClien
/// <summary>
/// <para>Runs multiple templated searches with a single request.</para>
/// </summary>
public sealed partial class MultiSearchTemplateRequestDescriptor<TDocument> : RequestDescriptor<MultiSearchTemplateRequestDescriptor<TDocument>, MultiSearchTemplateRequestParameters>
public sealed partial class MultiSearchTemplateRequestDescriptor<TDocument> : RequestDescriptor<MultiSearchTemplateRequestDescriptor<TDocument>, MultiSearchTemplateRequestParameters>, IStreamSerializable
{
internal MultiSearchTemplateRequestDescriptor(Action<MultiSearchTemplateRequestDescriptor<TDocument>> configure) => configure.Invoke(this);

public MultiSearchTemplateRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) : base(r => r.Optional("index", indices))
{
}

public MultiSearchTemplateRequestDescriptor() : this(typeof(TDocument))
public MultiSearchTemplateRequestDescriptor()
{
}

Expand Down Expand Up @@ -175,6 +175,28 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o

List<Elastic.Clients.Elasticsearch.Serverless.Core.MSearchTemplate.SearchTemplateRequestItem> _items = new();

void IStreamSerializable.Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
if (_items is null)
return;
foreach (var item in _items)
{
if (item is IStreamSerializable serializable)
serializable.Serialize(stream, settings, formatting);
}
}

async Task IStreamSerializable.SerializeAsync(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
if (_items is null)
return;
foreach (var item in _items)
{
if (item is IStreamSerializable serializable)
await serializable.SerializeAsync(stream, settings, formatting).ConfigureAwait(false);
}
}

public MultiSearchTemplateRequestDescriptor<TDocument> AddSearchTemplates(Elastic.Clients.Elasticsearch.Serverless.Core.MSearchTemplate.SearchTemplateRequestItem searchTemplates)
{
_items.Add(searchTemplates);
Expand All @@ -185,7 +207,7 @@ public MultiSearchTemplateRequestDescriptor<TDocument> AddSearchTemplates(Elasti
/// <summary>
/// <para>Runs multiple templated searches with a single request.</para>
/// </summary>
public sealed partial class MultiSearchTemplateRequestDescriptor : RequestDescriptor<MultiSearchTemplateRequestDescriptor, MultiSearchTemplateRequestParameters>
public sealed partial class MultiSearchTemplateRequestDescriptor : RequestDescriptor<MultiSearchTemplateRequestDescriptor, MultiSearchTemplateRequestParameters>, IStreamSerializable
{
internal MultiSearchTemplateRequestDescriptor(Action<MultiSearchTemplateRequestDescriptor> configure) => configure.Invoke(this);

Expand Down Expand Up @@ -223,6 +245,28 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o

List<Elastic.Clients.Elasticsearch.Serverless.Core.MSearchTemplate.SearchTemplateRequestItem> _items = new();

void IStreamSerializable.Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
if (_items is null)
return;
foreach (var item in _items)
{
if (item is IStreamSerializable serializable)
serializable.Serialize(stream, settings, formatting);
}
}

async Task IStreamSerializable.SerializeAsync(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting)
{
if (_items is null)
return;
foreach (var item in _items)
{
if (item is IStreamSerializable serializable)
await serializable.SerializeAsync(stream, settings, formatting).ConfigureAwait(false);
}
}

public MultiSearchTemplateRequestDescriptor AddSearchTemplates(Elastic.Clients.Elasticsearch.Serverless.Core.MSearchTemplate.SearchTemplateRequestItem searchTemplates)
{
_items.Add(searchTemplates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public RankEvalRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indice
{
}

public RankEvalRequestDescriptor() : this(typeof(TDocument))
public RankEvalRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ public SearchRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Indices?
{
}

public SearchRequestDescriptor() : this(typeof(TDocument))
public SearchRequestDescriptor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public SearchTemplateRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.
{
}

public SearchTemplateRequestDescriptor() : this(typeof(TDocument))
public SearchTemplateRequestDescriptor()
{
}

Expand Down
Loading
Loading