Skip to content

Commit f04802c

Browse files
committed
Implement AsyncSearch Status API
1 parent fec16ef commit f04802c

18 files changed

+218
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public TimeSpan WaitForCompletionTimeout
5959
}
6060

6161
///<summary>Request options for Status <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
62-
public class StatusRequestParameters : RequestParameters<StatusRequestParameters>
62+
public class AsyncSearchStatusRequestParameters : RequestParameters<AsyncSearchStatusRequestParameters>
6363
{
6464
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
6565
public override bool SupportsBody => false;

src/Elasticsearch.Net/ElasticLowLevelClient.AsyncSearch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ public Task<TResponse> GetAsync<TResponse>(string id, AsyncSearchGetRequestParam
6868
///<summary>GET on /_async_search/status/{id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
6969
///<param name = "id">The async search ID</param>
7070
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
71-
public TResponse Status<TResponse>(string id, StatusRequestParameters requestParameters = null)
71+
public TResponse Status<TResponse>(string id, AsyncSearchStatusRequestParameters requestParameters = null)
7272
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(GET, Url($"_async_search/status/{id:id}"), null, RequestParams(requestParameters));
7373
///<summary>GET on /_async_search/status/{id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
7474
///<param name = "id">The async search ID</param>
7575
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
7676
[MapsApi("async_search.status", "id")]
77-
public Task<TResponse> StatusAsync<TResponse>(string id, StatusRequestParameters requestParameters = null, CancellationToken ctx = default)
77+
public Task<TResponse> StatusAsync<TResponse>(string id, AsyncSearchStatusRequestParameters requestParameters = null, CancellationToken ctx = default)
7878
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_async_search/status/{id:id}"), ctx, null, RequestParams(requestParameters));
7979
///<summary>POST on /_async_search <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html</para></summary>
8080
///<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
@@ -78,6 +78,27 @@ protected AsyncSearchGetDescriptor(): base()
7878
public AsyncSearchGetDescriptor WaitForCompletionTimeout(Time waitforcompletiontimeout) => Qs("wait_for_completion_timeout", waitforcompletiontimeout);
7979
}
8080

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

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
@@ -117,6 +117,39 @@ public Time WaitForCompletionTimeout
117117
}
118118
}
119119

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

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 Elasticsearch.Net.Utf8Json;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Collections.Generic;
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
24

35
namespace Nest
46
{

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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Collections.Generic;
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
24

35
namespace Nest
46
{

0 commit comments

Comments
 (0)