Skip to content

Commit 49758d1

Browse files
committed
added support for SourceExists()
1 parent cf63e5c commit 49758d1

File tree

12 files changed

+373
-123
lines changed

12 files changed

+373
-123
lines changed

src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,68 +2292,68 @@ public class DocumentExistsRequestParameters : FluentRequestParameters<DocumentE
22922292
///http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
22932293
///</pre>
22942294
///</summary>
2295-
public class ExistsSourceRequestParameters : FluentRequestParameters<ExistsSourceRequestParameters>
2295+
public class SourceExistsRequestParameters : FluentRequestParameters<SourceExistsRequestParameters>
22962296
{
22972297
public override HttpMethod DefaultHttpMethod => HttpMethod.HEAD;
22982298

22992299
///<summary>The ID of the parent document</summary>
2300-
public ExistsSourceRequestParameters Parent(string parent) => this.AddQueryString("parent", parent);
2300+
public SourceExistsRequestParameters Parent(string parent) => this.AddQueryString("parent", parent);
23012301

23022302

23032303
///<summary>Specify the node or shard the operation should be performed on (default: random)</summary>
2304-
public ExistsSourceRequestParameters Preference(string preference) => this.AddQueryString("preference", preference);
2304+
public SourceExistsRequestParameters Preference(string preference) => this.AddQueryString("preference", preference);
23052305

23062306

23072307
///<summary>Specify whether to perform the operation in realtime or search mode</summary>
2308-
public ExistsSourceRequestParameters Realtime(bool realtime) => this.AddQueryString("realtime", realtime);
2308+
public SourceExistsRequestParameters Realtime(bool realtime) => this.AddQueryString("realtime", realtime);
23092309

23102310

23112311
///<summary>Refresh the shard containing the document before performing the operation</summary>
2312-
public ExistsSourceRequestParameters Refresh(bool refresh) => this.AddQueryString("refresh", refresh);
2312+
public SourceExistsRequestParameters Refresh(bool refresh) => this.AddQueryString("refresh", refresh);
23132313

23142314

23152315
///<summary>Specific routing value</summary>
2316-
public ExistsSourceRequestParameters Routing(string routing) => this.AddQueryString("routing", routing);
2316+
public SourceExistsRequestParameters Routing(string routing) => this.AddQueryString("routing", routing);
23172317

23182318

23192319
///<summary>True or false to return the _source field or not, or a list of fields to return</summary>
2320-
public ExistsSourceRequestParameters SourceEnabled(params string[] source_enabled) => this.AddQueryString("_source", source_enabled);
2320+
public SourceExistsRequestParameters SourceEnabled(params string[] source_enabled) => this.AddQueryString("_source", source_enabled);
23212321

23222322

23232323
///<summary>A list of fields to exclude from the returned _source field</summary>
2324-
public ExistsSourceRequestParameters SourceExclude(params string[] source_exclude) => this.AddQueryString("_source_exclude", source_exclude);
2324+
public SourceExistsRequestParameters SourceExclude(params string[] source_exclude) => this.AddQueryString("_source_exclude", source_exclude);
23252325

23262326

23272327
///<summary>A list of fields to extract and return from the _source field</summary>
2328-
public ExistsSourceRequestParameters SourceInclude(params string[] source_include) => this.AddQueryString("_source_include", source_include);
2328+
public SourceExistsRequestParameters SourceInclude(params string[] source_include) => this.AddQueryString("_source_include", source_include);
23292329

23302330

23312331
///<summary>Explicit version number for concurrency control</summary>
2332-
public ExistsSourceRequestParameters Version(long version) => this.AddQueryString("version", version);
2332+
public SourceExistsRequestParameters Version(long version) => this.AddQueryString("version", version);
23332333

23342334

23352335
///<summary>Specific version type</summary>
2336-
public ExistsSourceRequestParameters VersionType(VersionType version_type) => this.AddQueryString("version_type", version_type);
2336+
public SourceExistsRequestParameters VersionType(VersionType version_type) => this.AddQueryString("version_type", version_type);
23372337

23382338

23392339
///<summary>Pretty format the returned JSON response.</summary>
2340-
public ExistsSourceRequestParameters Pretty(bool pretty) => this.AddQueryString("pretty", pretty);
2340+
public SourceExistsRequestParameters Pretty(bool pretty) => this.AddQueryString("pretty", pretty);
23412341

23422342

23432343
///<summary>Return human readable values for statistics.</summary>
2344-
public ExistsSourceRequestParameters Human(bool human) => this.AddQueryString("human", human);
2344+
public SourceExistsRequestParameters Human(bool human) => this.AddQueryString("human", human);
23452345

23462346

23472347
///<summary>Include the stack trace of returned errors.</summary>
2348-
public ExistsSourceRequestParameters ErrorTrace(bool error_trace) => this.AddQueryString("error_trace", error_trace);
2348+
public SourceExistsRequestParameters ErrorTrace(bool error_trace) => this.AddQueryString("error_trace", error_trace);
23492349

23502350

23512351
///<summary>The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.</summary>
2352-
public ExistsSourceRequestParameters Source(string source) => this.AddQueryString("source", source);
2352+
public SourceExistsRequestParameters Source(string source) => this.AddQueryString("source", source);
23532353

23542354

23552355
///<summary>A comma-separated list of filters used to reduce the respone.</summary>
2356-
public ExistsSourceRequestParameters FilterPath(params string[] filter_path) => this.AddQueryString("filter_path", filter_path);
2356+
public SourceExistsRequestParameters FilterPath(params string[] filter_path) => this.AddQueryString("filter_path", filter_path);
23572357

23582358
}
23592359

src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,7 @@ public ElasticsearchResponse<T> Exists<T>(string index, string type, string id,
20042004
///<param name="type">The type of the document; use `_all` to fetch the first document matching the ID across all types</param>
20052005
///<param name="id">The document ID</param>
20062006
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2007-
public ElasticsearchResponse<T> ExistsSource<T>(string index, string type, string id, Func<ExistsSourceRequestParameters, ExistsSourceRequestParameters> requestParameters = null)
2007+
public ElasticsearchResponse<T> ExistsSource<T>(string index, string type, string id, Func<SourceExistsRequestParameters, SourceExistsRequestParameters> requestParameters = null)
20082008
where T : class => this.DoRequest<T>(HEAD, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}/_source"), null, _params(requestParameters));
20092009

20102010
///<summary>Represents a HEAD on /{index}/{type}/{id}/_source
@@ -2020,7 +2020,7 @@ public ElasticsearchResponse<T> ExistsSource<T>(string index, string type, strin
20202020
///<param name="type">The type of the document; use `_all` to fetch the first document matching the ID across all types</param>
20212021
///<param name="id">The document ID</param>
20222022
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
2023-
public Task<ElasticsearchResponse<T>> ExistsSourceAsync<T>(string index, string type, string id, Func<ExistsSourceRequestParameters, ExistsSourceRequestParameters> requestParameters = null, CancellationToken cancellationToken = default(CancellationToken))
2023+
public Task<ElasticsearchResponse<T>> ExistsSourceAsync<T>(string index, string type, string id, Func<SourceExistsRequestParameters, SourceExistsRequestParameters> requestParameters = null, CancellationToken cancellationToken = default(CancellationToken))
20242024
where T : class => this.DoRequestAsync<T>(HEAD, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}/_source"), cancellationToken, null, _params(requestParameters));
20252025

20262026
///<summary>Represents a GET on /{index}/{type}/{id}/_explain

src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ public partial interface IElasticLowLevelClient
18721872
///<param name="type">The type of the document; use `_all` to fetch the first document matching the ID across all types</param>
18731873
///<param name="id">The document ID</param>
18741874
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
1875-
ElasticsearchResponse<T> ExistsSource<T>(string index, string type, string id, Func<ExistsSourceRequestParameters, ExistsSourceRequestParameters> requestParameters = null) where T : class;
1875+
ElasticsearchResponse<T> ExistsSource<T>(string index, string type, string id, Func<SourceExistsRequestParameters, SourceExistsRequestParameters> requestParameters = null) where T : class;
18761876

18771877
///<summary>Represents a HEAD on /{index}/{type}/{id}/_source
18781878
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
@@ -1887,7 +1887,7 @@ public partial interface IElasticLowLevelClient
18871887
///<param name="type">The type of the document; use `_all` to fetch the first document matching the ID across all types</param>
18881888
///<param name="id">The document ID</param>
18891889
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
1890-
Task<ElasticsearchResponse<T>> ExistsSourceAsync<T>(string index, string type, string id, Func<ExistsSourceRequestParameters, ExistsSourceRequestParameters> requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class;
1890+
Task<ElasticsearchResponse<T>> ExistsSourceAsync<T>(string index, string type, string id, Func<SourceExistsRequestParameters, SourceExistsRequestParameters> requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class;
18911891

18921892
///<summary>Represents a GET on /{index}/{type}/{id}/_explain
18931893
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
using Elasticsearch.Net;
5+
6+
namespace Nest
7+
{
8+
using System.Threading;
9+
using ExistConverter = Func<IApiCallDetails, Stream, ExistsResponse>;
10+
11+
public partial interface IElasticClient
12+
{
13+
/// <summary>
14+
/// Check if a document's source exists without returning its contents
15+
/// <para> </para><a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-get.html">http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-get.html</a>
16+
/// </summary>
17+
/// <typeparam name="T">The type used to infer the default index and typename</typeparam>
18+
/// <param name="selector">Describe what document we are looking for</param>
19+
IExistsResponse SourceExists<T>(DocumentPath<T> document, Func<SourceExistsDescriptor<T>, ISourceExistsRequest> selector = null)
20+
where T : class;
21+
22+
/// <inheritdoc/>
23+
IExistsResponse SourceExists(ISourceExistsRequest request);
24+
25+
/// <inheritdoc/>
26+
Task<IExistsResponse> SourceExistsAsync<T>(DocumentPath<T> document, Func<SourceExistsDescriptor<T>, ISourceExistsRequest> selector = null, CancellationToken cancellationToken = default(CancellationToken))
27+
where T : class;
28+
29+
/// <inheritdoc/>
30+
Task<IExistsResponse> SourceExistsAsync(ISourceExistsRequest request, CancellationToken cancellationToken = default(CancellationToken));
31+
}
32+
33+
public partial class ElasticClient
34+
{
35+
/// <inheritdoc/>
36+
public IExistsResponse SourceExists<T>(DocumentPath<T> document, Func<SourceExistsDescriptor<T>, ISourceExistsRequest> selector = null) where T : class =>
37+
this.SourceExists(selector.InvokeOrDefault(new SourceExistsDescriptor<T>(document.Self.Index, document.Self.Type, document.Self.Id)));
38+
39+
/// <inheritdoc/>
40+
public IExistsResponse SourceExists(ISourceExistsRequest request) =>
41+
this.Dispatcher.Dispatch<ISourceExistsRequest, SourceExistsRequestParameters, ExistsResponse>(
42+
request,
43+
new ExistConverter(this.DeserializeExistsResponse),
44+
(p, d) => this.LowLevelDispatch.ExistsSourceDispatch<ExistsResponse>(p)
45+
);
46+
47+
/// <inheritdoc/>
48+
public Task<IExistsResponse> SourceExistsAsync<T>(DocumentPath<T> document, Func<SourceExistsDescriptor<T>, ISourceExistsRequest> selector = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class =>
49+
this.SourceExistsAsync(selector.InvokeOrDefault(new SourceExistsDescriptor<T>(document.Self.Index, document.Self.Type, document.Self.Id)), cancellationToken);
50+
51+
/// <inheritdoc/>
52+
public Task<IExistsResponse> SourceExistsAsync(ISourceExistsRequest request, CancellationToken cancellationToken = default(CancellationToken)) =>
53+
this.Dispatcher.DispatchAsync<ISourceExistsRequest, SourceExistsRequestParameters, ExistsResponse, IExistsResponse>(
54+
request,
55+
cancellationToken,
56+
new ExistConverter(this.DeserializeExistsResponse),
57+
(p, d, c) => this.LowLevelDispatch.ExistsSourceDispatchAsync<ExistsResponse>(p, c)
58+
);
59+
}
60+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Elasticsearch.Net;
2+
3+
namespace Nest
4+
{
5+
public partial interface ISourceExistsRequest { }
6+
7+
public interface ISourceExistsRequest<T> : ISourceExistsRequest where T : class { }
8+
9+
public partial class SourceExistsRequest { }
10+
11+
public partial class SourceExistsRequest<T> where T : class { }
12+
13+
[DescriptorFor("ExistsSource")]
14+
public partial class SourceExistsDescriptor<T> where T : class
15+
{
16+
}
17+
}

0 commit comments

Comments
 (0)