Skip to content

Commit cab53b5

Browse files
Implement common request query parameters for request descriptors (#8257) (#8258)
Co-authored-by: Florian Bernd <[email protected]>
1 parent 6a73ab0 commit cab53b5

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

src/Elastic.Clients.Elasticsearch.Shared/Core/Request/PlainRequest.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public bool? ErrorTrace
3030
}
3131

3232
/// <summary>
33-
/// A comma-separated list of filters used to reduce the response.
34-
/// <para>
35-
/// Use of response filtering can result in a response from Elasticsearch
36-
/// that cannot be correctly deserialized to the respective response type for the request.
37-
/// In such situations, use the low level client to issue the request and handle response deserialization.
38-
/// </para>
33+
/// A list of filters used to reduce the response.
34+
/// <para>
35+
/// Use of response filtering can result in a response from Elasticsearch
36+
/// that cannot be correctly deserialized to the respective response type for the request.
37+
/// In such situations, use the low level client to issue the request and handle response deserialization.
38+
/// </para>
3939
/// </summary>
4040
[JsonIgnore]
4141
public string[] FilterPath
@@ -44,7 +44,7 @@ public string[] FilterPath
4444
set => Q("filter_path", value);
4545
}
4646

47-
///<summary>Return human readable values for statistics.</summary>
47+
///<summary>Return human-readable values for statistics.</summary>
4848
[JsonIgnore]
4949
public bool? Human
5050
{

src/Elastic.Clients.Elasticsearch.Shared/Core/Request/Request.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ protected Request(Func<RouteValues, RouteValues> pathSelector)
8080

8181
[JsonIgnore] internal TParameters RequestParameters => _parameters;
8282

83-
protected TOut Q<TOut>(string name) => RequestParameters.GetQueryStringValue<TOut>(name);
83+
protected TOut? Q<TOut>(string name) => RequestParameters.GetQueryStringValue<TOut>(name);
8484

85-
protected void Q(string name, object value) => RequestParameters.SetQueryString(name, value);
85+
protected void Q(string name, object? value) => RequestParameters.SetQueryString(name, value);
8686

8787
protected void Q(string name, IStringable value) => RequestParameters.SetQueryString(name, value.GetString());
8888

src/Elastic.Clients.Elasticsearch.Shared/Core/Request/RequestDescriptor.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.ComponentModel;
77
using System.Text.Json;
8+
89
#if ELASTICSEARCH_SERVERLESS
910
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
1011
#else
@@ -40,7 +41,7 @@ internal RequestDescriptor(Func<RouteValues, RouteValues> pathSelector) : base(p
4041

4142
protected TDescriptor Self => _descriptor;
4243

43-
protected TDescriptor Qs(string name, object value)
44+
protected TDescriptor Qs(string name, object? value)
4445
{
4546
Q(name, value);
4647
return _descriptor;
@@ -64,6 +65,22 @@ public TDescriptor RequestConfiguration(
6465
return _descriptor;
6566
}
6667

68+
/// <summary>
69+
/// A list of filters used to reduce the response.
70+
/// <para>
71+
/// Use of response filtering can result in a response from Elasticsearch
72+
/// that cannot be correctly deserialized to the respective response type for the request.
73+
/// In such situations, use the low level client to issue the request and handle response deserialization.
74+
/// </para>
75+
/// </summary>
76+
public TDescriptor FilterPath(params string[] value) => Qs("filter_path", value);
77+
78+
///<summary>Return human-readable values for statistics.</summary>
79+
public TDescriptor Human(bool? value) => Qs("human", value);
80+
81+
///<summary>Pretty format the returned JSON response.</summary>
82+
public TDescriptor Pretty(bool? value) => Qs("pretty", value);
83+
6784
/// <summary>
6885
/// Hides the <see cref="ToString" /> method.
6986
/// </summary>

0 commit comments

Comments
 (0)