Skip to content

Commit 4aafd55

Browse files
authored
Align specification tweaks and naming with Java (#6982)
* Remove container suffixes * Manual type renaming to align with Java * Rename requests and responses to align with Java * Remove range query until ambiguous union is handled * EQL Get Status fixup * Skip SimpleQueryStringFlags until generated correctly * Eql API URLs
1 parent f8f92fc commit 4aafd55

File tree

294 files changed

+6043
-7914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+6043
-7914
lines changed

benchmarks/Benchmarks/Program.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -173,56 +173,56 @@ public class BulkIngest
173173
public void Version7()
174174
{
175175
Stream.Position = 0;
176-
_ = NestClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponse>(Stream);
176+
_ = NestClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponse>(Stream);
177177
}
178178

179179
[Benchmark]
180180
public void Version8()
181181
{
182182
Stream.Position = 0;
183-
_ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponse>(Stream);
183+
_ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponse>(Stream);
184184
}
185185

186186
// [Benchmark]
187187
// public void Version8_String()
188188
// {
189189
// Stream.Position = 0;
190-
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV2>(Stream);
190+
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV2>(Stream);
191191
// }
192192

193193
//[Benchmark]
194194
//public void Version8_String_Converter()
195195
//{
196196
// Stream.Position = 0;
197-
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV3>(Stream);
197+
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV3>(Stream);
198198
//}
199199

200200
//[Benchmark]
201201
//public void Version8_String_ConverterWithBool()
202202
//{
203203
// Stream.Position = 0;
204-
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV3_BoolFlags>(Stream);
204+
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV3_BoolFlags>(Stream);
205205
//}
206206

207207
//[Benchmark]
208208
//public void Version8_String_ConverterWithSpan()
209209
//{
210210
// Stream.Position = 0;
211-
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV3_Span>(Stream);
211+
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV3_Span>(Stream);
212212
//}
213213

214214
//[Benchmark]
215215
//public void Version8_SourceWithoutUsingContext()
216216
//{
217217
// Stream.Position = 0;
218-
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV4>(Stream);
218+
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV4>(Stream);
219219
//}
220220

221221
//[Benchmark]
222222
//public void Version8_SourceDirect()
223223
//{
224224
// Stream.Position = 0;
225-
// _ = JsonSerializer.Deserialize(Stream, Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV4Context.Default.ClusterHealthResponseV4);
225+
// _ = JsonSerializer.Deserialize(Stream, Elastic.Clients.Elasticsearch.Cluster.HealthResponseV4Context.Default.HealthResponseV4);
226226
//}
227227
}
228228

benchmarks/Profiling/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
//var observer = bulkAll.Wait(TimeSpan.FromMinutes(1), n => { });
3333

34-
_ = await alphaClient.RequestResponseSerializer.DeserializeAsync<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponse>(stream);
34+
_ = await alphaClient.RequestResponseSerializer.DeserializeAsync<Elastic.Clients.Elasticsearch.Cluster.HealthResponse>(stream);
3535

3636
MemoryProfiler.ForceGc();
3737

@@ -47,7 +47,7 @@
4747

4848
//observer = bulkAll.Wait(TimeSpan.FromMinutes(1), n => { });
4949

50-
var result = await alphaClient.RequestResponseSerializer.DeserializeAsync<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponse>(stream);
50+
var result = await alphaClient.RequestResponseSerializer.DeserializeAsync<Elastic.Clients.Elasticsearch.Cluster.HealthResponse>(stream);
5151

5252
MemoryProfiler.GetSnapshot();
5353

src/Elastic.Clients.Elasticsearch.JsonNetSerializer/ConnectionSettingsAwareContractResolver.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,31 @@ private void ApplyPropertyOverrides(MemberInfo member, JsonProperty property)
6464

6565
private static void ApplyShouldSerializer(JsonProperty property)
6666
{
67-
if (property.PropertyType == typeof(QueryContainer))
68-
property.ShouldSerialize = o => ShouldSerializeQueryContainer(o, property);
69-
else if (property.PropertyType == typeof(IEnumerable<QueryContainer>))
70-
property.ShouldSerialize = o => ShouldSerializeQueryContainers(o, property);
67+
if (property.PropertyType == typeof(Query))
68+
property.ShouldSerialize = o => ShouldSerializeQuery(o, property);
69+
else if (property.PropertyType == typeof(IEnumerable<Query>))
70+
property.ShouldSerialize = o => ShouldSerializeQuerys(o, property);
7171
}
7272

73-
private static bool ShouldSerializeQueryContainer(object o, JsonProperty prop)
73+
private static bool ShouldSerializeQuery(object o, JsonProperty prop)
7474
{
7575
if (o == null)
7676
return false;
77-
if (prop.ValueProvider.GetValue(o) is not QueryContainer q)
77+
if (prop.ValueProvider.GetValue(o) is not Query q)
7878
return false;
7979
//return q.IsWritable;
8080
return true;
8181
}
8282

83-
private static bool ShouldSerializeQueryContainers(object o, JsonProperty prop)
83+
private static bool ShouldSerializeQuerys(object o, JsonProperty prop)
8484
{
8585
if (o == null)
8686
return false;
87-
if (prop.ValueProvider.GetValue(o) is not IEnumerable<QueryContainer> q)
87+
if (prop.ValueProvider.GetValue(o) is not IEnumerable<Query> q)
8888
return false;
8989

90-
var queryContainers = q as QueryContainer[] ?? q.ToArray();
91-
//return queryContainers.Any(qq => qq != null && ((QueryContainer)qq).IsWritable);
90+
var queryContainers = q as Query[] ?? q.ToArray();
91+
//return queryContainers.Any(qq => qq != null && ((Query)qq).IsWritable);
9292
return queryContainers.Any(qq => qq != null);
9393
}
9494
}

src/Elastic.Clients.Elasticsearch.JsonNetSerializer/Converters/HandleNestTypesOnSourceJsonConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class HandleNestTypesOnSourceJsonConverter : JsonConverter
1818
private static readonly HashSet<Type> NestTypesThatCanAppearInSource = new()
1919
{
2020
typeof(JoinField),
21-
typeof(QueryContainer),
21+
typeof(Query),
2222
//typeof(CompletionField),
2323
//typeof(Attachment),
2424
typeof(LazyJson),

src/Elastic.Clients.Elasticsearch/Api/AsyncSearch/AsyncSearchSubmitRequest.cs renamed to src/Elastic.Clients.Elasticsearch/Api/AsyncSearch/SubmitAsyncSearchRequest.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77

88
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
99

10-
public partial class AsyncSearchSubmitRequest
10+
public partial class SubmitAsyncSearchRequest
1111
{
1212
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
1313
internal override void BeforeRequest() => TypedKeys = true;
1414
}
1515

16-
public sealed partial class AsyncSearchSubmitRequestDescriptor
16+
public sealed partial class SubmitAsyncSearchRequestDescriptor
1717
{
18-
public AsyncSearchSubmitRequestDescriptor MatchAll(Action<MatchAllQueryDescriptor>? selector = null) => selector is null ? Query(q => q.MatchAll()) : Query(q => q.MatchAll(selector));
18+
public SubmitAsyncSearchRequestDescriptor MatchAll(Action<MatchAllQueryDescriptor>? selector = null) => selector is null ? Query(q => q.MatchAll()) : Query(q => q.MatchAll(selector));
1919

2020
internal override void BeforeRequest() => TypedKeys(true);
2121
}
2222

23-
public sealed partial class AsyncSearchSubmitRequestDescriptor<TDocument>
23+
public sealed partial class SubmitAsyncSearchRequestDescriptor<TDocument>
2424
{
25-
public AsyncSearchSubmitRequestDescriptor<TDocument> MatchAll()
25+
public SubmitAsyncSearchRequestDescriptor<TDocument> MatchAll()
2626
{
2727
Query(new MatchAllQuery());
2828
return Self;

src/Elastic.Clients.Elasticsearch/Api/CountRequest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public CountRequestDescriptor Index(Indices indices)
3131
return Self;
3232
}
3333

34-
public CountRequestDescriptor Query(Func<QueryContainerDescriptor, QueryContainer> configure)
34+
public CountRequestDescriptor Query(Func<QueryDescriptor, Query> configure)
3535
{
36-
var container = configure?.Invoke(new QueryContainerDescriptor());
36+
var container = configure?.Invoke(new QueryDescriptor());
3737
QueryValue = container;
3838
return Self;
3939
}

src/Elastic.Clients.Elasticsearch/Api/Eql/GetEqlResponse.cs renamed to src/Elastic.Clients.Elasticsearch/Api/Eql/EqlGetResponse.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Elastic.Clients.Elasticsearch.Eql;
99

10-
public partial class GetEqlResponse<TEvent>
10+
public partial class EqlGetResponse<TEvent>
1111
{
1212
private IReadOnlyCollection<HitsEvent<TEvent>> _events;
1313
private IReadOnlyCollection<HitsSequence<TEvent>> _sequences;

src/Elastic.Clients.Elasticsearch/Api/SourceRequest.cs renamed to src/Elastic.Clients.Elasticsearch/Api/GetSourceRequestDescriptor.cs

+2-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@
44

55
namespace Elastic.Clients.Elasticsearch;
66

7-
// TODO - Should be added as a rule to the descriptor generator
8-
//public sealed partial class SourceRequestDescriptor<TDocument>
9-
//{
10-
// public SourceRequestDescriptor(TDocument documentWithId, IndexName index = null, Id id = null) : this(index ?? typeof(TDocument), id ?? Id.From(documentWithId)) => Doc
11-
//}
12-
13-
public partial class SourceRequestDescriptor
7+
public partial class GetSourceRequestDescriptor
148
{
159
/// <summary>
1610
/// A shortcut into calling Index(typeof(TOther)).
1711
/// </summary>
18-
public SourceRequestDescriptor Index<TOther>()
12+
public GetSourceRequestDescriptor Index<TOther>()
1913
{
2014
RouteValues.Required("index", (IndexName)typeof(TOther));
2115
return Self;

src/Elastic.Clients.Elasticsearch/Api/SourceResponse.cs renamed to src/Elastic.Clients.Elasticsearch/Api/GetSourceResponse.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Elastic.Clients.Elasticsearch;
1010

11-
public partial class SourceResponse<TDocument> : ISelfDeserializable
11+
public partial class GetSourceResponse<TDocument> : ISelfDeserializable
1212
{
1313
public TDocument Body { get; set; }
1414

src/Elastic.Clients.Elasticsearch/Api/IndexManagement/MappingResponse.cs renamed to src/Elastic.Clients.Elasticsearch/Api/IndexManagement/GetMappingResponse.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77

88
namespace Elastic.Clients.Elasticsearch.IndexManagement;
99

10-
public partial class MappingResponse
10+
public partial class GetMappingResponse
1111
{
1212
public IReadOnlyDictionary<IndexName, IndexMappingRecord> Indices => BackingDictionary;
1313
}
1414

1515
public static class GetMappingResponseExtensions
1616
{
17-
public static TypeMapping GetMappingFor<T>(this MappingResponse response) => response.GetMappingFor(typeof(T));
17+
public static TypeMapping GetMappingFor<T>(this GetMappingResponse response) => response.GetMappingFor(typeof(T));
1818

19-
public static TypeMapping GetMappingFor(this MappingResponse response, IndexName index)
19+
public static TypeMapping GetMappingFor(this GetMappingResponse response, IndexName index)
2020
{
2121
if (index.IsNullOrEmpty())
2222
return null;

src/Elastic.Clients.Elasticsearch/Api/Sql/SqlGetAsyncResponse.cs renamed to src/Elastic.Clients.Elasticsearch/Api/Sql/GetAsyncResponse.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Elastic.Clients.Elasticsearch.Sql;
99

10-
public partial class SqlGetAsyncResponse
10+
public partial class GetAsyncResponse
1111
{
1212
[JsonInclude]
1313
[JsonPropertyName("rows")]

src/Elastic.Clients.Elasticsearch/Core/Aggregations/AggregationCombinator.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace Elastic.Clients.Elasticsearch.Aggregations;
1010
/// <summary>
1111
/// Combines aggregations into a single list of aggregations.
1212
/// </summary>
13-
internal class AggregationCombinator : Aggregation
13+
internal class AggregationCombinator : SearchAggregation
1414
{
15-
public AggregationCombinator(string name, Aggregation left, Aggregation right)
15+
public AggregationCombinator(string name, SearchAggregation left, SearchAggregation right)
1616
{
1717
AddAggregation(left);
1818
AddAggregation(right);
@@ -21,9 +21,9 @@ public AggregationCombinator(string name, Aggregation left, Aggregation right)
2121

2222
public override string? Name { get; internal set; }
2323

24-
internal List<Aggregation> Aggregations { get; } = new List<Aggregation>();
24+
internal List<SearchAggregation> Aggregations { get; } = new List<SearchAggregation>();
2525

26-
private void AddAggregation(Aggregation agg)
26+
private void AddAggregation(SearchAggregation agg)
2727
{
2828
switch (agg)
2929
{

src/Elastic.Clients.Elasticsearch/Core/Aggregations/AggregationDictionary.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ namespace Elastic.Clients.Elasticsearch.Aggregations;
1111
/// <summary>
1212
/// Describes aggregations to execute as part of a search.
1313
/// </summary>
14-
public sealed class AggregationDictionary : IsADictionary<string, AggregationContainer>
14+
public sealed class AggregationDictionary : IsADictionary<string, Aggregation>
1515
{
1616
public AggregationDictionary() { }
1717

18-
public AggregationDictionary(IDictionary<string, AggregationContainer> dictionary)
18+
public AggregationDictionary(IDictionary<string, Aggregation> dictionary)
1919
: base(dictionary.ToDictionary(kv => kv.Key, kv => kv.Value)) { } // Copy the existing dictionary rather then using the existing reference
2020

21-
public AggregationDictionary(Dictionary<string, AggregationContainer> dictionary)
21+
public AggregationDictionary(Dictionary<string, Aggregation> dictionary)
2222
: base(dictionary.ToDictionary(kv => kv.Key, kv => kv.Value)) { } // Copy the existing dictionary rather then using the existing reference
2323

24-
public static implicit operator AggregationDictionary(Dictionary<string, AggregationContainer> dictionary) =>
24+
public static implicit operator AggregationDictionary(Dictionary<string, Aggregation> dictionary) =>
2525
new(dictionary);
2626

27-
public static implicit operator AggregationDictionary(Aggregation aggregator)
27+
public static implicit operator AggregationDictionary(SearchAggregation aggregator)
2828
{
29-
Aggregation b;
29+
SearchAggregation b;
3030
if (aggregator is AggregationCombinator combinator)
3131
{
3232
var dict = new AggregationDictionary();
@@ -49,9 +49,9 @@ public static implicit operator AggregationDictionary(Aggregation aggregator)
4949
return new AggregationDictionary { { aggregator } };
5050
}
5151

52-
public void Add(string key, AggregationContainer value) => BackingDictionary.Add(ValidateKey(key), value);
52+
public void Add(string key, Aggregation value) => BackingDictionary.Add(ValidateKey(key), value);
5353

54-
public void Add(AggregationContainer value)
54+
public void Add(Aggregation value)
5555
{
5656
if (value.Variant.Name.IsNullOrEmpty())
5757
throw new ArgumentException($"{value.GetType().Name}.Name is not set!");

src/Elastic.Clients.Elasticsearch/Core/Aggregations/Aggregation.cs renamed to src/Elastic.Clients.Elasticsearch/Core/Aggregations/SearchAggregation.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
namespace Elastic.Clients.Elasticsearch.Aggregations;
66

77
// This is marked as internal for now, until we are ready to support plugin aggregations.
8-
internal interface IAggregation
8+
internal interface ISearchAggregation
99
{
1010
string? Name { get; }
1111
}
1212

1313
/// <summary>
1414
/// Base class for all aggregations.
1515
/// </summary>
16-
public abstract class Aggregation : IAggregation
16+
public abstract class SearchAggregation : ISearchAggregation
1717
{
18-
internal Aggregation() { }
18+
internal SearchAggregation() { }
1919

2020
public abstract string? Name { get; internal set; }
2121

2222
//always evaluate to false so that each side of && equation is evaluated
23-
public static bool operator false(Aggregation _) => false;
23+
public static bool operator false(SearchAggregation _) => false;
2424

2525
//always evaluate to false so that each side of && equation is evaluated
26-
public static bool operator true(Aggregation _) => false;
26+
public static bool operator true(SearchAggregation _) => false;
2727

28-
public static Aggregation operator &(Aggregation left, Aggregation right) =>
28+
public static SearchAggregation operator &(SearchAggregation left, SearchAggregation right) =>
2929
new AggregationCombinator(null, left, right);
3030
}

src/Elastic.Clients.Elasticsearch/Core/Extensions/Extensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ internal static class Extensions
1919
{
2020
private static readonly ConcurrentDictionary<string, object> EnumCache = new();
2121

22-
//internal static bool NotWritable(this QueryContainer q) => q == null || !q.IsWritable;
22+
//internal static bool NotWritable(this Query q) => q == null || !q.IsWritable;
2323

24-
//internal static bool NotWritable(this IEnumerable<QueryContainer> qs) => qs == null || qs.All(q => q.NotWritable());
24+
//internal static bool NotWritable(this IEnumerable<Query> qs) => qs == null || qs.All(q => q.NotWritable());
2525

2626
internal static string ToEnumValue<T>(this T enumValue) where T : struct
2727
{

0 commit comments

Comments
 (0)