Skip to content

Commit 5eb532f

Browse files
committed
Implement AsyncSearch Status API (#5239)
1 parent bd964b9 commit 5eb532f

18 files changed

+220
-6
lines changed

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.AsyncSearch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public TimeSpan WaitForCompletionTimeout
5656
}
5757

5858
///<summary>Request options for Status <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
59-
public class StatusRequestParameters : RequestParameters<StatusRequestParameters>
59+
public class AsyncSearchStatusRequestParameters : RequestParameters<AsyncSearchStatusRequestParameters>
6060
{
6161
}
6262

src/Elasticsearch.Net/ElasticLowLevelClient.AsyncSearch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ public Task<TResponse> GetAsync<TResponse>(string id, AsyncSearchGetRequestParam
6969
///<summary>GET on /_async_search/status/{id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
7070
///<param name = "id">The async search ID</param>
7171
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
72-
public TResponse Status<TResponse>(string id, StatusRequestParameters requestParameters = null)
72+
public TResponse Status<TResponse>(string id, AsyncSearchStatusRequestParameters requestParameters = null)
7373
where TResponse : class, ITransportResponse, new() => DoRequest<TResponse>(GET, Url($"_async_search/status/{id:id}"), null, RequestParams(requestParameters));
7474
///<summary>GET on /_async_search/status/{id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
7575
///<param name = "id">The async search ID</param>
7676
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
7777
[MapsApi("async_search.status", "id")]
78-
public Task<TResponse> StatusAsync<TResponse>(string id, StatusRequestParameters requestParameters = null, CancellationToken ctx = default)
78+
public Task<TResponse> StatusAsync<TResponse>(string id, AsyncSearchStatusRequestParameters requestParameters = null, CancellationToken ctx = default)
7979
where TResponse : class, ITransportResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_async_search/status/{id:id}"), ctx, null, RequestParams(requestParameters));
8080
///<summary>POST on /_async_search <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
8181
///<param name = "body">The search definition using the Query DSL</param>

src/Nest/Descriptors.AsyncSearch.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ protected AsyncSearchGetDescriptor(): base()
8383
public AsyncSearchGetDescriptor WaitForCompletionTimeout(Time waitforcompletiontimeout) => Qs("wait_for_completion_timeout", waitforcompletiontimeout);
8484
}
8585

86+
///<summary>Descriptor for Status <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
87+
public partial class AsyncSearchStatusDescriptor : RequestDescriptorBase<AsyncSearchStatusDescriptor, AsyncSearchStatusRequestParameters, IAsyncSearchStatusRequest>, IAsyncSearchStatusRequest
88+
{
89+
internal override ApiUrls ApiUrls => ApiUrlsLookups.AsyncSearchStatus;
90+
///<summary>/_async_search/status/{id}</summary>
91+
///<param name = "id">this parameter is required</param>
92+
public AsyncSearchStatusDescriptor(Id id): base(r => r.Required("id", id))
93+
{
94+
}
95+
96+
///<summary>Used for serialization purposes, making sure we have a parameterless constructor</summary>
97+
[SerializationConstructor]
98+
protected AsyncSearchStatusDescriptor(): base()
99+
{
100+
}
101+
102+
// values part of the url path
103+
Id IAsyncSearchStatusRequest.Id => Self.RouteValues.Get<Id>("id");
104+
// Request parameters
105+
}
106+
86107
///<summary>Descriptor for Submit <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
87108
public partial class AsyncSearchSubmitDescriptor<TInferDocument> : RequestDescriptorBase<AsyncSearchSubmitDescriptor<TInferDocument>, AsyncSearchSubmitRequestParameters, IAsyncSearchSubmitRequest<TInferDocument>>, IAsyncSearchSubmitRequest<TInferDocument>
88109
{

src/Nest/ElasticClient.AsyncSearch.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,30 @@ public AsyncSearchGetResponse<TDocument> Get<TDocument>(IAsyncSearchGetRequest r
8989
public Task<AsyncSearchGetResponse<TDocument>> GetAsync<TDocument>(IAsyncSearchGetRequest request, CancellationToken ct = default)
9090
where TDocument : class => DoRequestAsync<IAsyncSearchGetRequest, AsyncSearchGetResponse<TDocument>>(request, request.RequestParameters, ct);
9191
/// <summary>
92+
/// <c>GET</c> request to the <c>async_search.status</c> API, read more about this API online:
93+
/// <para></para>
94+
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</a>
95+
/// </summary>
96+
public AsyncSearchStatusResponse Status(Id id, Func<AsyncSearchStatusDescriptor, IAsyncSearchStatusRequest> selector = null) => Status(selector.InvokeOrDefault(new AsyncSearchStatusDescriptor(id: id)));
97+
/// <summary>
98+
/// <c>GET</c> request to the <c>async_search.status</c> API, read more about this API online:
99+
/// <para></para>
100+
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</a>
101+
/// </summary>
102+
public Task<AsyncSearchStatusResponse> StatusAsync(Id id, Func<AsyncSearchStatusDescriptor, IAsyncSearchStatusRequest> selector = null, CancellationToken ct = default) => StatusAsync(selector.InvokeOrDefault(new AsyncSearchStatusDescriptor(id: id)), ct);
103+
/// <summary>
104+
/// <c>GET</c> request to the <c>async_search.status</c> API, read more about this API online:
105+
/// <para></para>
106+
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</a>
107+
/// </summary>
108+
public AsyncSearchStatusResponse Status(IAsyncSearchStatusRequest request) => DoRequest<IAsyncSearchStatusRequest, AsyncSearchStatusResponse>(request, request.RequestParameters);
109+
/// <summary>
110+
/// <c>GET</c> request to the <c>async_search.status</c> API, read more about this API online:
111+
/// <para></para>
112+
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</a>
113+
/// </summary>
114+
public Task<AsyncSearchStatusResponse> StatusAsync(IAsyncSearchStatusRequest request, CancellationToken ct = default) => DoRequestAsync<IAsyncSearchStatusRequest, AsyncSearchStatusResponse>(request, request.RequestParameters, ct);
115+
/// <summary>
92116
/// <c>POST</c> request to the <c>async_search.submit</c> API, read more about this API online:
93117
/// <para></para>
94118
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</a>

src/Nest/Requests.AsyncSearch.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,39 @@ public Time WaitForCompletionTimeout
122122
}
123123
}
124124

125+
[InterfaceDataContract]
126+
public partial interface IAsyncSearchStatusRequest : IRequest<AsyncSearchStatusRequestParameters>
127+
{
128+
[IgnoreDataMember]
129+
Id Id
130+
{
131+
get;
132+
}
133+
}
134+
135+
///<summary>Request for Status <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
136+
public partial class AsyncSearchStatusRequest : PlainRequestBase<AsyncSearchStatusRequestParameters>, IAsyncSearchStatusRequest
137+
{
138+
protected IAsyncSearchStatusRequest Self => this;
139+
internal override ApiUrls ApiUrls => ApiUrlsLookups.AsyncSearchStatus;
140+
///<summary>/_async_search/status/{id}</summary>
141+
///<param name = "id">this parameter is required</param>
142+
public AsyncSearchStatusRequest(Id id): base(r => r.Required("id", id))
143+
{
144+
}
145+
146+
///<summary>Used for serialization purposes, making sure we have a parameterless constructor</summary>
147+
[SerializationConstructor]
148+
protected AsyncSearchStatusRequest(): base()
149+
{
150+
}
151+
152+
// values part of the url path
153+
[IgnoreDataMember]
154+
Id IAsyncSearchStatusRequest.Id => Self.RouteValues.Get<Id>("id");
155+
// Request parameters
156+
}
157+
125158
[InterfaceDataContract]
126159
public partial interface IAsyncSearchSubmitRequest : IRequest<AsyncSearchSubmitRequestParameters>
127160
{

src/Nest/XPack/AsyncSearch/AsyncSearch.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
15
using System.Collections.Generic;
26
using System.Linq;
37
using System.Runtime.Serialization;

src/Nest/XPack/AsyncSearch/AsyncSearchResponseBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
15
using System;
26
using System.Runtime.Serialization;
37
using Nest.Utf8Json;

src/Nest/XPack/AsyncSearch/Delete/AsyncSearchDeleteRequest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
15
namespace Nest
26
{
37
[MapsApi("async_search.delete.json")]

src/Nest/XPack/AsyncSearch/Delete/AsyncSearchDeleteResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
15
namespace Nest
26
{
37
public class AsyncSearchDeleteResponse : AcknowledgedResponseBase { }

src/Nest/XPack/AsyncSearch/Get/AsyncSearchGetRequest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
15
namespace Nest
26
{
37
[MapsApi("async_search.get.json")]

0 commit comments

Comments
 (0)