diff --git a/src/Elastic.Clients.Elasticsearch.JsonNetSerializer/Converters/HandleNestTypesOnSourceJsonConverter.cs b/src/Elastic.Clients.Elasticsearch.JsonNetSerializer/Converters/HandleNestTypesOnSourceJsonConverter.cs
index 1c7e6a43297..09be35a7063 100644
--- a/src/Elastic.Clients.Elasticsearch.JsonNetSerializer/Converters/HandleNestTypesOnSourceJsonConverter.cs
+++ b/src/Elastic.Clients.Elasticsearch.JsonNetSerializer/Converters/HandleNestTypesOnSourceJsonConverter.cs
@@ -21,7 +21,7 @@ public class HandleNestTypesOnSourceJsonConverter : JsonConverter
typeof(QueryContainer),
//typeof(CompletionField),
//typeof(Attachment),
- typeof(LazyDocument),
+ typeof(LazyJson),
//typeof(GeoCoordinate),
typeof(GeoLocation),
//typeof(CartesianPoint),
diff --git a/src/Elastic.Clients.Elasticsearch/Common/Fields/FieldValue.cs b/src/Elastic.Clients.Elasticsearch/Common/Fields/FieldValue.cs
new file mode 100644
index 00000000000..692836ec624
--- /dev/null
+++ b/src/Elastic.Clients.Elasticsearch/Common/Fields/FieldValue.cs
@@ -0,0 +1,392 @@
+// Licensed to Elasticsearch B.V under one or more agreements.
+// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information.
+
+using System.Text.Json.Serialization;
+using System.Text.Json;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Collections.Generic;
+
+namespace Elastic.Clients.Elasticsearch
+{
+ ///
+ /// Represents a value for a field which depends on the field mapping and is only known at runtime,
+ /// therefore cannot be specifically typed.
+ ///
+ [JsonConverter(typeof(FieldValueConverter))]
+ public readonly struct FieldValue : IEquatable
+ {
+ internal FieldValue(ValueKind kind, object? value) { Kind = kind; Value = value; }
+
+ ///
+ /// The kind of value contained within this .
+ ///
+ public readonly ValueKind Kind { get; }
+
+ ///
+ /// The value contained within within this .
+ ///
+ public readonly object? Value { get; }
+
+ ///
+ /// An enumeration of the possible value kinds that the may contain.
+ ///
+ public enum ValueKind
+ {
+ Null,
+ Double,
+ Long,
+ Boolean,
+ String,
+ LazyDocument,
+ Composite
+ }
+
+ ///
+ /// Represents a null value.
+ ///
+ public static FieldValue Null { get; } = new(ValueKind.Null, null);
+
+ ///
+ /// Represents a true boolean value.
+ ///
+ public static FieldValue True { get; } = new(ValueKind.Boolean, true);
+
+ ///
+ /// Represents a false boolean value.
+ ///
+ public static FieldValue False { get; } = new(ValueKind.Boolean, false);
+
+ ///
+ /// Factory method to create a containing a long value.
+ ///
+ /// The long to store as the value.
+ /// The new .
+ public static FieldValue Long(long value) => new(ValueKind.Long, value);
+
+ ///
+ /// Factory method to create a containing a boolean value.
+ ///
+ /// The boolean to store as the value.
+ /// The new .
+ public static FieldValue Boolean(bool value) => new(ValueKind.Boolean, value);
+
+ ///
+ /// Factory method to create a containing a double value.
+ ///
+ /// The double to store as the value.
+ /// The new .
+ public static FieldValue Double(double value) => new(ValueKind.Double, value);
+
+ ///
+ /// Factory method to create a containing a string value.
+ ///
+ /// The string to store as the value.
+ /// The new .
+ public static FieldValue String(string value) => new(ValueKind.String, value);
+
+ // These are not expected to be required for consumer values but are used internally.
+ internal static FieldValue Any(LazyJson value) => new(ValueKind.LazyDocument, value);
+ internal static FieldValue Composite(object value) => new(ValueKind.Composite, value);
+
+ ///
+ /// Checks if the value of .
+ ///
+ public bool IsString => Kind == ValueKind.String;
+
+ ///
+ /// Checks if the value of .
+ ///
+ public bool IsBool => Kind == ValueKind.Boolean;
+
+ ///
+ /// Checks if the value of .
+ ///
+ public bool IsLong => Kind == ValueKind.Long;
+
+ ///
+ /// Checks if the value of .
+ ///
+ public bool IsDouble => Kind == ValueKind.Double;
+
+ ///
+ /// Checks if the value of .
+ ///
+ public bool IsLazyDocument => Kind == ValueKind.LazyDocument;
+
+ ///
+ /// Checks if the value of .
+ ///
+ public bool IsNull => Kind == ValueKind.Null;
+
+ ///
+ /// Checks if the value of .
+ ///
+ public bool IsComposite => Kind == ValueKind.Composite;
+
+ ///
+ /// Gets the value when the value kind is .
+ ///
+ /// When this method returns, contains the value associated with this ,
+ /// if the value kind is ; otherwise, the default value for the type of the value parameter.
+ /// This parameter is passed uninitialized.
+ /// True if the value is a .
+ public bool TryGetString([NotNullWhen(returnValue: true)] out string? value)
+ {
+ value = null;
+
+ if (!IsString)
+ return false;
+
+ value = (string)Value;
+ return true;
+ }
+
+ ///
+ /// Gets the value when the value kind is .
+ ///
+ /// When this method returns, contains the value associated with this ,
+ /// if the value kind is ; otherwise, the default value for the type of the value parameter.
+ /// This parameter is passed uninitialized.
+ /// True if the value is a .
+ public bool TryGetBool([NotNullWhen(returnValue: true)] out bool? value)
+ {
+ value = null;
+
+ if (!IsBool)
+ return false;
+
+ value = (bool)Value;
+ return true;
+ }
+
+ ///
+ /// Gets the value when the value kind is .
+ ///
+ /// When this method returns, contains the value associated with this ,
+ /// if the value kind is ; otherwise, the default value for the type of the value parameter.
+ /// This parameter is passed uninitialized.
+ /// True if the value is a .
+ public bool TryGetLong([NotNullWhen(returnValue: true)] out long? value)
+ {
+ value = null;
+
+ if (!IsLong)
+ return false;
+
+ value = (long)Value;
+ return true;
+ }
+
+ ///
+ /// Gets the value when the value kind is .
+ ///
+ /// When this method returns, contains the value associated with this ,
+ /// if the value kind is ; otherwise, the default value for the type of the value parameter.
+ /// This parameter is passed uninitialized.
+ /// True if the value is a .
+ public bool TryGetDouble([NotNullWhen(returnValue: true)] out double? value)
+ {
+ value = null;
+
+ if (!IsDouble)
+ return false;
+
+ value = (double)Value;
+ return true;
+ }
+
+ ///
+ /// Gets the value when the value kind is .
+ ///
+ /// When this method returns, contains the value associated with this ,
+ /// if the value kind is ; otherwise, the default value for the type of the value parameter.
+ /// This parameter is passed uninitialized.
+ /// True if the value is a .
+ public bool TryGetLazyDocument([NotNullWhen(returnValue: true)] out LazyJson? value)
+ {
+ value = null;
+
+ if (!IsLazyDocument)
+ return false;
+
+ value = (LazyJson)Value;
+ return true;
+ }
+
+ ///
+ /// Gets the value when the value kind is and the value type is .
+ ///
+ /// The type expected for the value.
+ /// When this method returns, contains the value associated with this ,
+ /// if the value kind is and the value type is ; otherwise, the default
+ /// value for the type of the value parameter. This parameter is passed uninitialized.
+ /// True if the value is of the specified type.
+ public bool TryGet([NotNullWhen(returnValue: true)] out T? value)
+ {
+ value = default;
+
+ if (!IsComposite || Value is not T typedValue)
+ return false;
+
+ value = typedValue;
+ return true;
+ }
+
+ internal bool TryGetComposite([NotNullWhen(returnValue: true)] out object? value)
+ {
+ value = default;
+
+ if (!IsComposite)
+ return false;
+
+ value = Value;
+ return true;
+ }
+
+ public override string ToString()
+ {
+ if (Kind == ValueKind.String)
+ {
+ return Value as string;
+ }
+ else if (Kind == ValueKind.Double)
+ {
+ return ((double)Value).ToString();
+ }
+ else if (Kind == ValueKind.Long)
+ {
+ return ((long)Value).ToString();
+ }
+ else if (Kind == ValueKind.Boolean)
+ {
+ return ((bool)Value).ToString();
+ }
+ else if (Kind == ValueKind.Null)
+ {
+ return "null";
+ }
+ else if (Kind == ValueKind.LazyDocument || Kind == ValueKind.Composite)
+ {
+ throw new InvalidOperationException("Composite field value cannot be formatted as a string.");
+ }
+ else
+ {
+ throw new InvalidOperationException($"Unknown kind '{Kind}'");
+ }
+ }
+
+ public override bool Equals(object? obj) => obj is FieldValue value && Equals(value);
+ public bool Equals(FieldValue other) => Kind == other.Kind && EqualityComparer.Default.Equals(Value, other.Value);
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ var hashCode = 1484969029;
+ hashCode = hashCode * -1521134295 + Kind.GetHashCode();
+ hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Value);
+ return hashCode;
+ }
+ }
+
+ public static bool operator ==(FieldValue left, FieldValue right) => left.Equals(right);
+ public static bool operator !=(FieldValue left, FieldValue right) => !(left == right);
+
+ public static implicit operator FieldValue(string value) => String(value);
+ public static implicit operator FieldValue(bool value) => Boolean(value);
+ public static implicit operator FieldValue(int value) => Long(value);
+ public static implicit operator FieldValue(long value) => Long(value);
+ public static implicit operator FieldValue(double value) => Double(value);
+ }
+
+ internal sealed class FieldValueConverter : JsonConverter
+ {
+ public override FieldValue Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ switch (reader.TokenType)
+ {
+ case JsonTokenType.Null:
+ return FieldValue.Null;
+
+ case JsonTokenType.String:
+ var stringValue = reader.GetString();
+ return FieldValue.String(stringValue);
+
+ case JsonTokenType.Number:
+ if (reader.TryGetInt64(out var l))
+ {
+ return FieldValue.Long(l);
+ }
+ else if (reader.TryGetDouble(out var d))
+ {
+ return FieldValue.Double(d);
+ }
+ else
+ {
+ throw new JsonException("Unexpected number format which cannot be deserialised as a FieldValue.");
+ }
+
+ case JsonTokenType.True:
+ return FieldValue.True;
+
+ case JsonTokenType.False:
+ return FieldValue.False;
+
+ case JsonTokenType.StartObject:
+ case JsonTokenType.StartArray:
+ var value = JsonSerializer.Deserialize(ref reader, options);
+ return FieldValue.Any(value);
+ }
+
+ throw new JsonException($"Unexpected token type '{reader.TokenType}' read while deserializing a FieldValue.");
+ }
+
+ public override void Write(Utf8JsonWriter writer, FieldValue value, JsonSerializerOptions options)
+ {
+ if (value.TryGetString(out var stringValue))
+ {
+ writer.WriteStringValue(stringValue);
+ }
+
+ else if (value.TryGetBool(out var boolValue))
+ {
+ writer.WriteBooleanValue(boolValue.Value);
+ }
+
+ else if (value.TryGetLong(out var longValue))
+ {
+ writer.WriteNumberValue(longValue.Value);
+ }
+
+ else if (value.TryGetDouble(out var doubleValue))
+ {
+ writer.WriteNumberValue(doubleValue.Value);
+ }
+
+ else if (value.TryGetLazyDocument(out var lazyDocument))
+ {
+ writer.WriteRawValue(lazyDocument.Value.Bytes);
+ }
+
+ else if (value.TryGetComposite(out var objectValue))
+ {
+ if (!options.TryGetClientSettings(out var settings))
+ throw new JsonException("Unable to retrieve ElasticsearchClientSettings in order to access source serializer.");
+
+ SourceSerialisation.Serialize(objectValue, objectValue.GetType(), writer, settings);
+ }
+
+ else if (value.Kind == FieldValue.ValueKind.Null)
+ {
+ writer.WriteNullValue();
+ }
+
+ else
+ {
+ throw new JsonException($"Unsupported FieldValue kind. This is likely a bug and should be reported as an issue.");
+ }
+ }
+ }
+}
diff --git a/src/Elastic.Clients.Elasticsearch/Common/Fields/FieldValues.cs b/src/Elastic.Clients.Elasticsearch/Common/Fields/FieldValues.cs
index 5a980b645fb..72f7151df8e 100644
--- a/src/Elastic.Clients.Elasticsearch/Common/Fields/FieldValues.cs
+++ b/src/Elastic.Clients.Elasticsearch/Common/Fields/FieldValues.cs
@@ -12,7 +12,7 @@
namespace Elastic.Clients.Elasticsearch
{
[JsonConverter(typeof(FieldValuesConverter))]
- public sealed class FieldValues : IsADictionaryBase
+ public sealed class FieldValues : IsADictionaryBase
{
public static readonly FieldValues Empty = new();
@@ -28,7 +28,7 @@ public sealed class FieldValues : IsADictionaryBase
private FieldValues() { }
- internal FieldValues(Inferrer inferrer, IDictionary container)
+ internal FieldValues(Inferrer inferrer, IDictionary container)
: base(container) => _inferrer = inferrer;
public TValue Value(Field field)
@@ -109,7 +109,7 @@ internal sealed class FieldValuesConverter : JsonConverter
return null;
}
- var fields = new Dictionary();
+ var fields = new Dictionary();
while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
{
@@ -118,7 +118,7 @@ internal sealed class FieldValuesConverter : JsonConverter
var propertyName = reader.GetString();
reader.Read();
- var lazyDocument = JsonSerializer.Deserialize(ref reader, options);
+ var lazyDocument = JsonSerializer.Deserialize(ref reader, options);
fields[propertyName] = lazyDocument;
}
diff --git a/src/Elastic.Clients.Elasticsearch/Common/LazyDocument.cs b/src/Elastic.Clients.Elasticsearch/Common/LazyJson.cs
similarity index 56%
rename from src/Elastic.Clients.Elasticsearch/Common/LazyDocument.cs
rename to src/Elastic.Clients.Elasticsearch/Common/LazyJson.cs
index d847629a6e1..597e56bbccb 100644
--- a/src/Elastic.Clients.Elasticsearch/Common/LazyDocument.cs
+++ b/src/Elastic.Clients.Elasticsearch/Common/LazyJson.cs
@@ -9,13 +9,13 @@
namespace Elastic.Clients.Elasticsearch
{
///
- /// A lazily deserialized document.
- /// Holds raw JSON bytes which can be lazily converted to a specific at a later time.
+ /// Lazily deserializable JSON.
+ /// Holds raw JSON bytes which can be lazily deserialized to a specific using the source serializer at a later time.
///
- [JsonConverter(typeof(LazyDocumentConverter))]
- public readonly struct LazyDocument
+ [JsonConverter(typeof(LazyJsonConverter))]
+ public readonly struct LazyJson
{
- internal LazyDocument(byte[] bytes, IElasticsearchClientSettings settings)
+ internal LazyJson(byte[] bytes, IElasticsearchClientSettings settings)
{
Bytes = bytes;
Settings = settings;
@@ -26,7 +26,7 @@ internal LazyDocument(byte[] bytes, IElasticsearchClientSettings settings)
///
/// Creates an instance of from this
- /// instance.
+ /// instance.
///
/// The type
public T? As()
@@ -39,13 +39,13 @@ internal LazyDocument(byte[] bytes, IElasticsearchClientSettings settings)
}
}
- internal sealed class LazyDocumentConverter : JsonConverter
+ internal sealed class LazyJsonConverter : JsonConverter
{
private readonly IElasticsearchClientSettings _settings;
- public LazyDocumentConverter(IElasticsearchClientSettings settings) => _settings = settings;
+ public LazyJsonConverter(IElasticsearchClientSettings settings) => _settings = settings;
- public override LazyDocument Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public override LazyJson Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
using var jsonDoc = JsonSerializer.Deserialize(ref reader);
using var stream = _settings.MemoryStreamFactory.Create();
@@ -54,9 +54,9 @@ public override LazyDocument Read(ref Utf8JsonReader reader, Type typeToConvert,
jsonDoc.WriteTo(writer);
writer.Flush();
- return new LazyDocument(stream.ToArray(), _settings);
+ return new LazyJson(stream.ToArray(), _settings);
}
- public override void Write(Utf8JsonWriter writer, LazyDocument value, JsonSerializerOptions options) => throw new NotImplementedException("We only ever expect to deserialize a LazyDocument on responses.");
+ public override void Write(Utf8JsonWriter writer, LazyJson value, JsonSerializerOptions options) => throw new NotImplementedException("We only ever expect to deserialize LazyJson on responses.");
}
}
diff --git a/src/Elastic.Clients.Elasticsearch/Experimental/AggregateDictionaryExtensions.cs b/src/Elastic.Clients.Elasticsearch/Experimental/AggregateDictionaryExtensions.cs
new file mode 100644
index 00000000000..4f302e9d53f
--- /dev/null
+++ b/src/Elastic.Clients.Elasticsearch/Experimental/AggregateDictionaryExtensions.cs
@@ -0,0 +1,85 @@
+// Licensed to Elasticsearch B.V under one or more agreements.
+// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information.
+
+using Elastic.Clients.Elasticsearch.Aggregations;
+using System;
+using System.Linq;
+
+namespace Elastic.Clients.Elasticsearch.Experimental
+{
+ internal static class AggregateDictionaryExtensions
+ {
+ ///
+ /// WARNING: EXPERIMENTAL API
+ /// This API provides simplified access to terms aggregations.
+ ///
+ /// Experimental APIs are subject to changes or removal and should be used with caution.
+ public static TermsAggregate GetTerms(this AggregateDictionary aggregationDictionary, string key) => aggregationDictionary.GetTerms(key);
+
+ ///
+ /// WARNING: EXPERIMENTAL API
+ /// This API provides simplified access to terms aggregations.
+ ///
+ /// Experimental APIs are subject to changes or removal and should be used with caution.
+ public static TermsAggregate GetTerms(this AggregateDictionary aggregationDictionary, string key)
+ {
+ if (!aggregationDictionary.TryGetValue(key, out var agg))
+ {
+ return null;
+ }
+
+ switch (agg)
+ {
+ case StringTermsAggregate stringTerms:
+ var buckets = stringTerms.Buckets.Select(b => new TermsBucket(b.BackingDictionary) { DocCount = b.DocCount, DocCountError = b.DocCountError, Key = GetKeyFromBucketKey(b.Key), KeyAsString = b.Key.ToString() }).ToReadOnlyCollection(); // ToString is a temp hack here
+ return new TermsAggregate
+ {
+ Buckets = buckets,
+ Meta = stringTerms.Meta,
+ DocCountErrorUpperBound = stringTerms.DocCountErrorUpperBound,
+ SumOtherDocCount = stringTerms.SumOtherDocCount
+ };
+
+ case DoubleTermsAggregate doubleTerms:
+ var doubleTermsBuckets = doubleTerms.Buckets.Select(b => new TermsBucket(b.BackingDictionary) { DocCount = b.DocCount, DocCountError = b.DocCountError, Key = GetKeyFromBucketKey(b.Key), KeyAsString = b.KeyAsString }).ToReadOnlyCollection();
+ return new TermsAggregate
+ {
+ Buckets = doubleTermsBuckets,
+ Meta = doubleTerms.Meta,
+ DocCountErrorUpperBound = doubleTerms.DocCountErrorUpperBound,
+ SumOtherDocCount = doubleTerms.SumOtherDocCount
+ };
+
+ case LongTermsAggregate longTerms:
+ var longTermsBuckets = longTerms.Buckets.Select(b => new TermsBucket(b.BackingDictionary) { DocCount = b.DocCount, DocCountError = b.DocCountError, Key = GetKeyFromBucketKey(b.Key), KeyAsString = b.KeyAsString }).ToReadOnlyCollection();
+ return new TermsAggregate
+ {
+ Buckets = longTermsBuckets,
+ Meta = longTerms.Meta,
+ DocCountErrorUpperBound = longTerms.DocCountErrorUpperBound,
+ SumOtherDocCount = longTerms.SumOtherDocCount
+ };
+
+ // TODO - Multi-terms
+ }
+
+ return null;
+ }
+
+ private static TKey GetKeyFromBucketKey(object key)
+ {
+ if (typeof(TKey).IsEnum)
+ {
+ return (TKey)Enum.Parse(typeof(TKey), key.ToString(), true);
+ }
+
+ if (key is FieldValue fieldValue)
+ {
+ return (TKey)Convert.ChangeType(fieldValue.Value, typeof(TKey));
+ }
+
+ return (TKey)Convert.ChangeType(key, typeof(TKey));
+ }
+ }
+}
diff --git a/src/Elastic.Clients.Elasticsearch/Serialization/DefaultRequestResponseSerializer.cs b/src/Elastic.Clients.Elasticsearch/Serialization/DefaultRequestResponseSerializer.cs
index e56183774f2..5e70955a26d 100644
--- a/src/Elastic.Clients.Elasticsearch/Serialization/DefaultRequestResponseSerializer.cs
+++ b/src/Elastic.Clients.Elasticsearch/Serialization/DefaultRequestResponseSerializer.cs
@@ -37,7 +37,7 @@ public DefaultRequestResponseSerializer(IElasticsearchClientSettings settings)
new IdConverter(settings),
new FieldConverter(settings),
new FieldValuesConverter(settings),
- new LazyDocumentConverter(settings),
+ new LazyJsonConverter(settings),
new RelationNameConverter(settings),
new JoinFieldConverter(settings),
new CustomJsonWriterConverterFactory(settings),
diff --git a/src/Elastic.Clients.Elasticsearch/Serialization/DefaultSourceSerializer.cs b/src/Elastic.Clients.Elasticsearch/Serialization/DefaultSourceSerializer.cs
index a51a502629d..3b59a3975a5 100644
--- a/src/Elastic.Clients.Elasticsearch/Serialization/DefaultSourceSerializer.cs
+++ b/src/Elastic.Clients.Elasticsearch/Serialization/DefaultSourceSerializer.cs
@@ -21,7 +21,7 @@ public DefaultSourceSerializer(IElasticsearchClientSettings settings, JsonSerial
new RelationNameConverter(settings),
new RoutingConverter(settings),
new JoinFieldConverter(settings),
- new LazyDocumentConverter(settings),
+ new LazyJsonConverter(settings),
new IdsConverter(settings)
},
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
diff --git a/src/Elastic.Clients.Elasticsearch/Serialization/SourceSerialisation.cs b/src/Elastic.Clients.Elasticsearch/Serialization/SourceSerialisation.cs
index a9470428235..6af0684d17c 100644
--- a/src/Elastic.Clients.Elasticsearch/Serialization/SourceSerialisation.cs
+++ b/src/Elastic.Clients.Elasticsearch/Serialization/SourceSerialisation.cs
@@ -57,6 +57,9 @@ public static T DeserializeParams(ref Utf8JsonReader reader, IElasticsearchCl
public static void Serialize(T toSerialize, Utf8JsonWriter writer, IElasticsearchClientSettings settings) =>
Serialize(toSerialize, writer, settings.SourceSerializer);
+ public static void Serialize(object toSerialize, Type type, Utf8JsonWriter writer, IElasticsearchClientSettings settings) =>
+ Serialize(toSerialize, type, writer, settings.SourceSerializer);
+
public static void Serialize(T toSerialize, Utf8JsonWriter writer, Serializer sourceSerializer)
{
if (sourceSerializer is DefaultSourceSerializer defaultSerializer)
@@ -83,6 +86,32 @@ public static void Serialize(T toSerialize, Utf8JsonWriter writer, Serializer
#endif
}
+ public static void Serialize(object toSerialize, Type type, Utf8JsonWriter writer, Serializer sourceSerializer)
+ {
+ if (sourceSerializer is DefaultSourceSerializer defaultSerializer)
+ {
+ // When the serializer is our own, which uses STJ we can avoid unneccesary allocations and serialise straight into the writer
+ // In most cases this is not the case as it's wrapped in the DiagnosticsSerializerProxy
+ // Ideally, we'd short-circuit here if we know there are no listeners or avoid wrapping the default source serializer.
+ JsonSerializer.Serialize(writer, toSerialize, type, defaultSerializer.Options);
+ return;
+ }
+
+ // We may be using a custom serializer or most likely, we're registered via DiagnosticsSerializerProxy
+ // We cannot use STJ since the implementation may use another serializer.
+ // This path is a little less optimal
+ using var ms = new MemoryStream();
+ sourceSerializer.Serialize(toSerialize, ms);
+ ms.Position = 0;
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(ms.GetBuffer().AsSpan()[..(int)ms.Length], true);
+#else
+ // This is not super efficient but a variant on the suggestion at https://github.com/dotnet/runtime/issues/1784#issuecomment-608331125
+ using var document = JsonDocument.Parse(ms);
+ document.RootElement.WriteTo(writer);
+#endif
+ }
+
public static T Deserialize(ref Utf8JsonReader reader, IElasticsearchClientSettings settings)
{
var sourceSerializer = settings.SourceSerializer;
diff --git a/src/Elastic.Clients.Elasticsearch/Serialization/TermsAggregateSerializationHelper.cs b/src/Elastic.Clients.Elasticsearch/Serialization/TermsAggregateSerializationHelper.cs
index 06abf039ab1..d1ba447f9ac 100644
--- a/src/Elastic.Clients.Elasticsearch/Serialization/TermsAggregateSerializationHelper.cs
+++ b/src/Elastic.Clients.Elasticsearch/Serialization/TermsAggregateSerializationHelper.cs
@@ -15,7 +15,7 @@ internal static class TermsAggregateSerializationHelper
private static readonly byte[] s_key = Encoding.UTF8.GetBytes("key");
private static readonly byte s_period = (byte)'.';
- public static bool TryDeserialiseTermsAggregate(ref Utf8JsonReader reader, JsonSerializerOptions options, out IAggregate? aggregate)
+ public static bool TryDeserialiseTermsAggregate(string aggregateName, ref Utf8JsonReader reader, JsonSerializerOptions options, out IAggregate? aggregate)
{
aggregate = null;
@@ -31,9 +31,35 @@ public static bool TryDeserialiseTermsAggregate(ref Utf8JsonReader reader, JsonS
if (readerCopy.TokenType == JsonTokenType.EndArray) // We have no buckets
{
- var agg = JsonSerializer.Deserialize(ref reader, options);
- aggregate = agg;
- return true;
+ if (aggregateName.Equals("sterms", StringComparison.Ordinal))
+ {
+ var agg = JsonSerializer.Deserialize(ref reader, options);
+ aggregate = agg;
+ return true;
+ }
+
+ if (aggregateName.Equals("lterms", StringComparison.Ordinal))
+ {
+ var agg = JsonSerializer.Deserialize(ref reader, options);
+ aggregate = agg;
+ return true;
+ }
+
+ if (aggregateName.Equals("dterms", StringComparison.Ordinal))
+ {
+ var agg = JsonSerializer.Deserialize(ref reader, options);
+ aggregate = agg;
+ return true;
+ }
+
+ if (aggregateName.Equals("multi_terms", StringComparison.Ordinal))
+ {
+ var agg = JsonSerializer.Deserialize(ref reader, options);
+ aggregate = agg;
+ return true;
+ }
+
+ throw new JsonException($"Unable to deserialize empty terms aggregate for '{aggregateName}'.");
}
else
{
diff --git a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionary.cs b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionary.cs
index 03bb99058bd..eeddd8cf2ff 100644
--- a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionary.cs
+++ b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionary.cs
@@ -2,103 +2,11 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
namespace Elastic.Clients.Elasticsearch.Aggregations
{
public partial class AggregateDictionary
{
- public EmptyTermsAggregate? EmptyTerms(string key) => TryGet(key);
-
- public bool IsEmptyTerms(string key) => !BackingDictionary.TryGetValue(key, out var agg) || agg is EmptyTermsAggregate;
-
- // This should be autogenerated if we want to include this.
- //public bool TryGetStringTerms(string key, out StringTermsAggregate? aggregate)
- //{
- // aggregate = null;
-
- // if (BackingDictionary.TryGetValue(key, out var agg) && agg is StringTermsAggregate stringTermsAgg)
- // {
- // aggregate = stringTermsAgg;
- // return true;
- // }
-
- // return false;
- //}
-
+ ///
public AvgAggregate? GetAverage(string key) => TryGet(key);
-
- ///
- /// WARNING: EXPERIMENTAL API
- /// This API provides simplified access to terms aggregations.
- ///
- /// Experimental APIs are subject to changes or removal and should be used with caution.
- public TermsAggregate GetTerms(string key) => GetTerms(key);
-
- ///
- /// WARNING: EXPERIMENTAL API
- /// This API provides simplified access to terms aggregations.
- ///
- /// Experimental APIs are subject to changes or removal and should be used with caution.
- public TermsAggregate GetTerms(string key)
- {
- if (!BackingDictionary.TryGetValue(key, out var agg))
- {
- return null;
- }
-
- switch (agg)
- {
- case EmptyTermsAggregate empty:
- return new TermsAggregate
- {
- Buckets = Array.Empty>().ToReadOnlyCollection(),
- Meta = empty.Meta,
- DocCountErrorUpperBound = empty.DocCountErrorUpperBound,
- SumOtherDocCount = empty.SumOtherDocCount
- };
-
- case StringTermsAggregate stringTerms:
- var buckets = stringTerms.Buckets.Select(b => new TermsBucket(b.BackingDictionary) { DocCount = b.DocCount, DocCountError = b.DocCountError, Key = GetKeyFromBucketKey(b.Key), KeyAsString = b.Key }).ToReadOnlyCollection();
- return new TermsAggregate
- {
- Buckets = buckets,
- Meta = stringTerms.Meta,
- DocCountErrorUpperBound = stringTerms.DocCountErrorUpperBound,
- SumOtherDocCount = stringTerms.SumOtherDocCount
- };
-
- case DoubleTermsAggregate doubleTerms:
- var doubleTermsBuckets = doubleTerms.Buckets.Select(b => new TermsBucket(b.BackingDictionary) { DocCount = b.DocCount, DocCountError = b.DocCountError, Key = GetKeyFromBucketKey(b.Key), KeyAsString = b.KeyAsString }).ToReadOnlyCollection();
- return new TermsAggregate
- {
- Buckets = doubleTermsBuckets,
- Meta = doubleTerms.Meta,
- DocCountErrorUpperBound = doubleTerms.DocCountErrorUpperBound,
- SumOtherDocCount = doubleTerms.SumOtherDocCount
- };
-
- case LongTermsAggregate longTerms:
- var longTermsBuckets = longTerms.Buckets.Select(b => new TermsBucket(b.BackingDictionary) { DocCount = b.DocCount, DocCountError = b.DocCountError, Key = GetKeyFromBucketKey(b.Key), KeyAsString = b.KeyAsString }).ToReadOnlyCollection();
- return new TermsAggregate
- {
- Buckets = longTermsBuckets,
- Meta = longTerms.Meta,
- DocCountErrorUpperBound = longTerms.DocCountErrorUpperBound,
- SumOtherDocCount = longTerms.SumOtherDocCount
- };
-
- // TODO - Multi-terms
- }
-
- return null;
- }
-
- private static TKey GetKeyFromBucketKey(object key) =>
- typeof(TKey).IsEnum
- ? (TKey)Enum.Parse(typeof(TKey), key.ToString(), true)
- : (TKey)Convert.ChangeType(key, typeof(TKey));
}
}
diff --git a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs
index cf6ac4355e7..47890fa2bce 100644
--- a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs
+++ b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs
@@ -49,8 +49,9 @@ public static void ReadAggregate(ref Utf8JsonReader reader, JsonSerializerOption
case "terms":
case "sterms":
case "lterms":
+ case "dterms":
{
- if (TermsAggregateSerializationHelper.TryDeserialiseTermsAggregate(ref reader, options, out var agg))
+ if (TermsAggregateSerializationHelper.TryDeserialiseTermsAggregate(aggregateName, ref reader, options, out var agg))
{
dictionary.Add(nameParts[1], agg);
}
diff --git a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/EmptyTermsAggregate.cs b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/EmptyTermsAggregate.cs
index 42cf200b0a4..4380d1febf2 100644
--- a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/EmptyTermsAggregate.cs
+++ b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/EmptyTermsAggregate.cs
@@ -7,22 +7,22 @@
namespace Elastic.Clients.Elasticsearch.Aggregations
{
- public sealed class EmptyTermsAggregate : IAggregate
- {
- [JsonInclude]
- [JsonPropertyName("doc_count_error_upper_bound")]
- public long? DocCountErrorUpperBound { get; init; }
+ //public sealed class EmptyTermsAggregate : IAggregate
+ //{
+ // [JsonInclude]
+ // [JsonPropertyName("doc_count_error_upper_bound")]
+ // public long? DocCountErrorUpperBound { get; init; }
- [JsonInclude]
- [JsonPropertyName("sum_other_doc_count")]
- public long SumOtherDocCount { get; init; }
+ // [JsonInclude]
+ // [JsonPropertyName("sum_other_doc_count")]
+ // public long SumOtherDocCount { get; init; }
- [JsonInclude]
- [JsonPropertyName("buckets")]
- public Buckets> Buckets { get; init; }
+ // [JsonInclude]
+ // [JsonPropertyName("buckets")]
+ // public Buckets> Buckets { get; init; }
- [JsonInclude]
- [JsonPropertyName("meta")]
- public Dictionary? Meta { get; init; }
- }
+ // [JsonInclude]
+ // [JsonPropertyName("meta")]
+ // public Dictionary? Meta { get; init; }
+ //}
}
diff --git a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/TermsAggregate.cs b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/TermsAggregate.cs
index e411204472c..72639e77612 100644
--- a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/TermsAggregate.cs
+++ b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/TermsAggregate.cs
@@ -15,7 +15,7 @@ public sealed class TermsAggregate : IAggregate
[JsonInclude]
[JsonPropertyName("sum_other_doc_count")]
- public long SumOtherDocCount { get; init; }
+ public long? SumOtherDocCount { get; init; }
[JsonInclude]
[JsonPropertyName("buckets")]
diff --git a/src/Elastic.Clients.Elasticsearch/Types/QueryDsl/QueryContainerDescriptor.cs b/src/Elastic.Clients.Elasticsearch/Types/QueryDsl/QueryContainerDescriptor.cs
index 400feba5336..f68582497ea 100644
--- a/src/Elastic.Clients.Elasticsearch/Types/QueryDsl/QueryContainerDescriptor.cs
+++ b/src/Elastic.Clients.Elasticsearch/Types/QueryDsl/QueryContainerDescriptor.cs
@@ -13,7 +13,7 @@ public void MatchAll() =>
Set(_ => { }, "match_all");
public void Term(Expression> field, object value, float? boost = null) =>
- Term(t => t.Field(field).Value(value).Boost(boost));
+ Term(t => t.Field(field).Value(FieldValue.Composite(value)).Boost(boost));
}
public sealed partial class QueryContainerDescriptor/**/
@@ -27,5 +27,5 @@ public void MatchAll() =>
// Term(t => t.Field(field).Value(value).Boost(boost).Name(name));
public void Term(Expression> field, object value, float? boost = null) =>
- Term(t => t.Field(field).Value(value).Boost(boost));
+ Term(t => t.Field(field).Value(FieldValue.Composite(value)).Boost(boost));
}
diff --git a/src/Elastic.Clients.Elasticsearch/Types/Sql/SqlValue.cs b/src/Elastic.Clients.Elasticsearch/Types/Sql/SqlValue.cs
index 775f043b357..edd5d94d6c5 100644
--- a/src/Elastic.Clients.Elasticsearch/Types/Sql/SqlValue.cs
+++ b/src/Elastic.Clients.Elasticsearch/Types/Sql/SqlValue.cs
@@ -11,9 +11,9 @@ namespace Elastic.Clients.Elasticsearch.Sql;
[JsonConverter(typeof(SqlValueConverter))]
public readonly struct SqlValue
{
- private readonly LazyDocument _lazyDocument;
+ private readonly LazyJson _lazyDocument;
- internal SqlValue(LazyDocument lazyDocument) => _lazyDocument = lazyDocument;
+ internal SqlValue(LazyJson lazyDocument) => _lazyDocument = lazyDocument;
public T? As() => _lazyDocument.As();
}
@@ -28,7 +28,7 @@ public override SqlValue Read(ref Utf8JsonReader reader, Type typeToConvert, Jso
return default;
}
- var lazyDoc = JsonSerializer.Deserialize(ref reader, options);
+ var lazyDoc = JsonSerializer.Deserialize(ref reader, options);
return new SqlValue(lazyDoc);
}
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchSubmitRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchSubmitRequest.g.cs
index 0b360f860f0..b6792cfaf38 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchSubmitRequest.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchSubmitRequest.g.cs
@@ -234,7 +234,7 @@ public override AsyncSearchSubmitRequest Read(ref Utf8JsonReader reader, Type ty
if (property == "search_after")
{
- variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options);
+ variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options);
continue;
}
@@ -708,7 +708,7 @@ public AsyncSearchSubmitRequest(Elastic.Clients.Elasticsearch.Indices? indices)
[JsonInclude]
[JsonPropertyName("search_after")]
- public IEnumerable? SearchAfter { get; set; }
+ public IEnumerable? SearchAfter { get; set; }
[JsonInclude]
[JsonPropertyName("size")]
@@ -917,7 +917,7 @@ public AsyncSearchSubmitRequestDescriptor Indices(Elastic.Clients.Ela
private Dictionary? ScriptFieldsValue { get; set; }
- private IEnumerable? SearchAfterValue { get; set; }
+ private IEnumerable? SearchAfterValue { get; set; }
private bool? SeqNoPrimaryTermValue { get; set; }
@@ -1299,7 +1299,7 @@ public AsyncSearchSubmitRequestDescriptor ScriptFields(Func SearchAfter(IEnumerable? searchAfter)
+ public AsyncSearchSubmitRequestDescriptor SearchAfter(IEnumerable? searchAfter)
{
SearchAfterValue = searchAfter;
return Self;
@@ -1335,12 +1335,6 @@ public AsyncSearchSubmitRequestDescriptor StoredFields(Elastic.Client
return Self;
}
- public AsyncSearchSubmitRequestDescriptor StoredFields(Expression> storedFields)
- {
- StoredFieldsValue = storedFields;
- return Self;
- }
-
public AsyncSearchSubmitRequestDescriptor Suggest(Elastic.Clients.Elasticsearch.Suggester? suggest)
{
SuggestDescriptor = null;
@@ -1897,7 +1891,7 @@ public AsyncSearchSubmitRequestDescriptor Indices(Elastic.Clients.Elasticsearch.
private Dictionary? ScriptFieldsValue { get; set; }
- private IEnumerable? SearchAfterValue { get; set; }
+ private IEnumerable? SearchAfterValue { get; set; }
private bool? SeqNoPrimaryTermValue { get; set; }
@@ -2279,7 +2273,7 @@ public AsyncSearchSubmitRequestDescriptor ScriptFields(Func? searchAfter)
+ public AsyncSearchSubmitRequestDescriptor SearchAfter(IEnumerable? searchAfter)
{
SearchAfterValue = searchAfter;
return Self;
@@ -2315,18 +2309,6 @@ public AsyncSearchSubmitRequestDescriptor StoredFields(Elastic.Clients.Elasticse
return Self;
}
- public AsyncSearchSubmitRequestDescriptor StoredFields(Expression> storedFields)
- {
- StoredFieldsValue = storedFields;
- return Self;
- }
-
- public AsyncSearchSubmitRequestDescriptor StoredFields(Expression> storedFields)
- {
- StoredFieldsValue = storedFields;
- return Self;
- }
-
public AsyncSearchSubmitRequestDescriptor Suggest(Elastic.Clients.Elasticsearch.Suggester? suggest)
{
SuggestDescriptor = null;
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs
index 83b3b7d39e9..449180cbe49 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs
@@ -33,7 +33,7 @@ public sealed class DeleteByQueryRethrottleRequestParameters : RequestParameters
public sealed partial class DeleteByQueryRethrottleRequest : PlainRequestBase
{
- public DeleteByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.Id task_id) : base(r => r.Required("task_id", task_id))
+ public DeleteByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.TaskId task_id) : base(r => r.Required("task_id", task_id))
{
}
@@ -47,7 +47,7 @@ public DeleteByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.Id task_id)
public sealed partial class DeleteByQueryRethrottleRequestDescriptor : RequestDescriptorBase
{
internal DeleteByQueryRethrottleRequestDescriptor(Action configure) => configure.Invoke(this);
- public DeleteByQueryRethrottleRequestDescriptor(Elastic.Clients.Elasticsearch.Id task_id) : base(r => r.Required("task_id", task_id))
+ public DeleteByQueryRethrottleRequestDescriptor(Elastic.Clients.Elasticsearch.TaskId task_id) : base(r => r.Required("task_id", task_id))
{
}
@@ -59,7 +59,7 @@ internal DeleteByQueryRethrottleRequestDescriptor()
protected override HttpMethod HttpMethod => HttpMethod.POST;
protected override bool SupportsBody => false;
public DeleteByQueryRethrottleRequestDescriptor RequestsPerSecond(float? requestsPerSecond) => Qs("requests_per_second", requestsPerSecond);
- public DeleteByQueryRethrottleRequestDescriptor TaskId(Elastic.Clients.Elasticsearch.Id task_id)
+ public DeleteByQueryRethrottleRequestDescriptor TaskId(Elastic.Clients.Elasticsearch.TaskId task_id)
{
RouteValues.Required("task_id", task_id);
return Self;
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs
index c393d76d950..3db09548b9c 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs
@@ -34,7 +34,7 @@ public sealed class FieldCapsRequestParameters : RequestParameters? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); }
[JsonIgnore]
- public Elastic.Clients.Elasticsearch.Fields Fields { get => Q("fields"); set => Q("fields", value); }
+ public Elastic.Clients.Elasticsearch.Fields? Fields { get => Q("fields"); set => Q("fields", value); }
[JsonIgnore]
public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); }
@@ -69,7 +69,7 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r
public IEnumerable? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); }
[JsonIgnore]
- public Elastic.Clients.Elasticsearch.Fields Fields { get => Q("fields"); set => Q("fields", value); }
+ public Elastic.Clients.Elasticsearch.Fields? Fields { get => Q("fields"); set => Q("fields", value); }
[JsonIgnore]
public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); }
@@ -104,7 +104,7 @@ public FieldCapsRequestDescriptor()
protected override bool SupportsBody => true;
public FieldCapsRequestDescriptor AllowNoIndices(bool? allowNoIndices = true) => Qs("allow_no_indices", allowNoIndices);
public FieldCapsRequestDescriptor ExpandWildcards(IEnumerable? expandWildcards) => Qs("expand_wildcards", expandWildcards);
- public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields fields) => Qs("fields", fields);
+ public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? fields) => Qs("fields", fields);
public FieldCapsRequestDescriptor Filters(string? filters) => Qs("filters", filters);
public FieldCapsRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable);
public FieldCapsRequestDescriptor IncludeUnmapped(bool? includeUnmapped = true) => Qs("include_unmapped", includeUnmapped);
@@ -194,7 +194,7 @@ public FieldCapsRequestDescriptor()
protected override bool SupportsBody => true;
public FieldCapsRequestDescriptor AllowNoIndices(bool? allowNoIndices = true) => Qs("allow_no_indices", allowNoIndices);
public FieldCapsRequestDescriptor ExpandWildcards(IEnumerable? expandWildcards) => Qs("expand_wildcards", expandWildcards);
- public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields fields) => Qs("fields", fields);
+ public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? fields) => Qs("fields", fields);
public FieldCapsRequestDescriptor Filters(string? filters) => Qs("filters", filters);
public FieldCapsRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable);
public FieldCapsRequestDescriptor IncludeUnmapped(bool? includeUnmapped = true) => Qs("include_unmapped", includeUnmapped);
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs
index 49bf0d014d5..6fb09ec9ad4 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs
@@ -27,5 +27,9 @@ public sealed partial class ForcemergeResponse : ElasticsearchResponseBase
[JsonInclude]
[JsonPropertyName("_shards")]
public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; }
+
+ [JsonInclude]
+ [JsonPropertyName("task")]
+ public string? Task { get; init; }
}
}
\ No newline at end of file
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs
index 63bd25b5329..5293f3db6fc 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs
@@ -225,7 +225,7 @@ public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert
if (property == "search_after")
{
- variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options);
+ variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options);
continue;
}
@@ -690,7 +690,7 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r =>
[JsonInclude]
[JsonPropertyName("search_after")]
- public IEnumerable? SearchAfter { get; set; }
+ public IEnumerable? SearchAfter { get; set; }
[JsonInclude]
[JsonPropertyName("size")]
@@ -900,7 +900,7 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.
private Dictionary? ScriptFieldsValue { get; set; }
- private IEnumerable? SearchAfterValue { get; set; }
+ private IEnumerable? SearchAfterValue { get; set; }
private bool? SeqNoPrimaryTermValue { get; set; }
@@ -1282,7 +1282,7 @@ public SearchRequestDescriptor ScriptFields(Func SearchAfter(IEnumerable? searchAfter)
+ public SearchRequestDescriptor SearchAfter(IEnumerable? searchAfter)
{
SearchAfterValue = searchAfter;
return Self;
@@ -1318,12 +1318,6 @@ public SearchRequestDescriptor StoredFields(Elastic.Clients.Elasticse
return Self;
}
- public SearchRequestDescriptor StoredFields(Expression> storedFields)
- {
- StoredFieldsValue = storedFields;
- return Self;
- }
-
public SearchRequestDescriptor Suggest(Elastic.Clients.Elasticsearch.Suggester? suggest)
{
SuggestDescriptor = null;
@@ -1881,7 +1875,7 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? in
private Dictionary? ScriptFieldsValue { get; set; }
- private IEnumerable? SearchAfterValue { get; set; }
+ private IEnumerable? SearchAfterValue { get; set; }
private bool? SeqNoPrimaryTermValue { get; set; }
@@ -2263,7 +2257,7 @@ public SearchRequestDescriptor ScriptFields(Func? searchAfter)
+ public SearchRequestDescriptor SearchAfter(IEnumerable? searchAfter)
{
SearchAfterValue = searchAfter;
return Self;
@@ -2299,18 +2293,6 @@ public SearchRequestDescriptor StoredFields(Elastic.Clients.Elasticsearch.Fields
return Self;
}
- public SearchRequestDescriptor StoredFields(Expression> storedFields)
- {
- StoredFieldsValue = storedFields;
- return Self;
- }
-
- public SearchRequestDescriptor StoredFields(Expression> storedFields)
- {
- StoredFieldsValue = storedFields;
- return Self;
- }
-
public SearchRequestDescriptor Suggest(Elastic.Clients.Elasticsearch.Suggester? suggest)
{
SuggestDescriptor = null;
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs
index 2230022dfcd..85331e54fdf 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs
@@ -390,14 +390,14 @@ public Task DeleteByQueryRethrottleAsync(Delete
return DoRequestAsync(request, cancellationToken);
}
- public DeleteByQueryRethrottleResponse DeleteByQueryRethrottle(Elastic.Clients.Elasticsearch.Id task_id)
+ public DeleteByQueryRethrottleResponse DeleteByQueryRethrottle(Elastic.Clients.Elasticsearch.TaskId task_id)
{
var descriptor = new DeleteByQueryRethrottleRequestDescriptor(task_id);
descriptor.BeforeRequest();
return DoRequest(descriptor);
}
- public DeleteByQueryRethrottleResponse DeleteByQueryRethrottle(Elastic.Clients.Elasticsearch.Id task_id, Action configureRequest)
+ public DeleteByQueryRethrottleResponse DeleteByQueryRethrottle(Elastic.Clients.Elasticsearch.TaskId task_id, Action configureRequest)
{
var descriptor = new DeleteByQueryRethrottleRequestDescriptor(task_id);
configureRequest?.Invoke(descriptor);
@@ -405,14 +405,14 @@ public DeleteByQueryRethrottleResponse DeleteByQueryRethrottle(Elastic.Clients.E
return DoRequest(descriptor);
}
- public Task DeleteByQueryRethrottleAsync(Elastic.Clients.Elasticsearch.Id task_id, CancellationToken cancellationToken = default)
+ public Task DeleteByQueryRethrottleAsync(Elastic.Clients.Elasticsearch.TaskId task_id, CancellationToken cancellationToken = default)
{
var descriptor = new DeleteByQueryRethrottleRequestDescriptor(task_id);
descriptor.BeforeRequest();
return DoRequestAsync(descriptor);
}
- public Task DeleteByQueryRethrottleAsync(Elastic.Clients.Elasticsearch.Id task_id, Action configureRequest, CancellationToken cancellationToken = default)
+ public Task DeleteByQueryRethrottleAsync(Elastic.Clients.Elasticsearch.TaskId task_id, Action configureRequest, CancellationToken cancellationToken = default)
{
var descriptor = new DeleteByQueryRethrottleRequestDescriptor(task_id);
configureRequest?.Invoke(descriptor);
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/AggregationProfileDebug.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/AggregationProfileDebug.g.cs
index 9d1e49fff47..602882fc5ac 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/AggregationProfileDebug.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/AggregationProfileDebug.g.cs
@@ -78,6 +78,10 @@ public sealed partial class AggregationProfileDebug
[JsonPropertyName("has_filter")]
public bool? HasFilter { get; init; }
+ [JsonInclude]
+ [JsonPropertyName("map_reducer")]
+ public string? MapReducer { get; init; }
+
[JsonInclude]
[JsonPropertyName("numeric_collectors_used")]
public int? NumericCollectorsUsed { get; init; }
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/AggregationProfileDelegateDebugFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/AggregationProfileDelegateDebugFilter.g.cs
index bfafa000808..6afa8420c7e 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/AggregationProfileDelegateDebugFilter.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/AggregationProfileDelegateDebugFilter.g.cs
@@ -34,6 +34,10 @@ public sealed partial class AggregationProfileDelegateDebugFilter
[JsonPropertyName("results_from_metadata")]
public int? ResultsFromMetadata { get; init; }
+ [JsonInclude]
+ [JsonPropertyName("segments_counted_in_constant_time")]
+ public int? SegmentsCountedInConstantTime { get; init; }
+
[JsonInclude]
[JsonPropertyName("specialized_for")]
public string? SpecializedFor { get; init; }
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs
index c930563dd66..366a013e159 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs
@@ -34,6 +34,10 @@ public AdjacencyMatrixBucket(IReadOnlyDictionary backingDict
[JsonInclude]
[JsonPropertyName("doc_count")]
public long DocCount { get; init; }
+
+ [JsonInclude]
+ [JsonPropertyName("key")]
+ public string Key { get; init; }
}
internal sealed class AdjacencyMatrixBucketConverter : JsonConverter
@@ -44,6 +48,7 @@ internal sealed class AdjacencyMatrixBucketConverter : JsonConverter(); // TODO - Optimise this and only create if we need it.
long docCount = default;
+ string key = default;
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
@@ -58,6 +63,12 @@ internal sealed class AdjacencyMatrixBucketConverter : JsonConverter(ref reader, options);
+ continue;
+ }
+
if (name.Contains("#"))
{
AggregateDictionaryConverter.ReadAggregate(ref reader, options, subAggs, name);
@@ -68,7 +79,7 @@ internal sealed class AdjacencyMatrixBucketConverter : JsonConverter throw new NotImplementedException();
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregation.g.cs
index 1de9db3f094..6f54faede02 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregation.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregation.g.cs
@@ -63,6 +63,18 @@ public override AverageAggregation Read(ref Utf8JsonReader reader, Type typeToCo
continue;
}
+ if (reader.ValueTextEquals("missing"))
+ {
+ reader.Read();
+ var value = JsonSerializer.Deserialize(ref reader, options);
+ if (value is not null)
+ {
+ agg.Missing = value;
+ }
+
+ continue;
+ }
+
if (reader.ValueTextEquals("script"))
{
reader.Read();
@@ -114,6 +126,12 @@ public override void Write(Utf8JsonWriter writer, AverageAggregation value, Json
writer.WriteStringValue(value.Format);
}
+ if (value.Missing is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, value.Missing, options);
+ }
+
if (value.Script is not null)
{
writer.WritePropertyName("script");
@@ -146,6 +164,8 @@ internal AverageAggregation()
public Dictionary? Meta { get; set; }
+ public FieldValue? Missing { get; set; }
+
public override string? Name { get; internal set; }
public Elastic.Clients.Elasticsearch.Script? Script { get; set; }
@@ -164,6 +184,8 @@ public AverageAggregationDescriptor() : base()
private Dictionary? MetaValue { get; set; }
+ private FieldValue? MissingValue { get; set; }
+
private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; }
public AverageAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field)
@@ -190,6 +212,12 @@ public AverageAggregationDescriptor Meta(Func Missing(FieldValue? missing)
+ {
+ MissingValue = missing;
+ return Self;
+ }
+
public AverageAggregationDescriptor Script(Elastic.Clients.Elasticsearch.Script? script)
{
ScriptValue = script;
@@ -213,6 +241,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
writer.WriteStringValue(FormatValue);
}
+ if (MissingValue is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, MissingValue, options);
+ }
+
if (ScriptValue is not null)
{
writer.WritePropertyName("script");
@@ -243,6 +277,8 @@ public AverageAggregationDescriptor() : base()
private Dictionary? MetaValue { get; set; }
+ private FieldValue? MissingValue { get; set; }
+
private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; }
public AverageAggregationDescriptor Field(Elastic.Clients.Elasticsearch.Field? field)
@@ -275,6 +311,12 @@ public AverageAggregationDescriptor Meta(Func,
return Self;
}
+ public AverageAggregationDescriptor Missing(FieldValue? missing)
+ {
+ MissingValue = missing;
+ return Self;
+ }
+
public AverageAggregationDescriptor Script(Elastic.Clients.Elasticsearch.Script? script)
{
ScriptValue = script;
@@ -298,6 +340,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
writer.WriteStringValue(FormatValue);
}
+ if (MissingValue is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, MissingValue, options);
+ }
+
if (ScriptValue is not null)
{
writer.WritePropertyName("script");
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregation.g.cs
index d5059cf46ec..a930629d6ef 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregation.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregation.g.cs
@@ -63,6 +63,18 @@ public override BoxplotAggregation Read(ref Utf8JsonReader reader, Type typeToCo
continue;
}
+ if (reader.ValueTextEquals("missing"))
+ {
+ reader.Read();
+ var value = JsonSerializer.Deserialize(ref reader, options);
+ if (value is not null)
+ {
+ agg.Missing = value;
+ }
+
+ continue;
+ }
+
if (reader.ValueTextEquals("script"))
{
reader.Read();
@@ -114,6 +126,12 @@ public override void Write(Utf8JsonWriter writer, BoxplotAggregation value, Json
JsonSerializer.Serialize(writer, value.Field, options);
}
+ if (value.Missing is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, value.Missing, options);
+ }
+
if (value.Script is not null)
{
writer.WritePropertyName("script");
@@ -146,6 +164,8 @@ internal BoxplotAggregation()
public Dictionary? Meta { get; set; }
+ public FieldValue? Missing { get; set; }
+
public override string? Name { get; internal set; }
public Elastic.Clients.Elasticsearch.Script? Script { get; set; }
@@ -164,6 +184,8 @@ public BoxplotAggregationDescriptor() : base()
private Dictionary? MetaValue { get; set; }
+ private FieldValue? MissingValue { get; set; }
+
private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; }
public BoxplotAggregationDescriptor Compression(double? compression)
@@ -190,6 +212,12 @@ public BoxplotAggregationDescriptor Meta(Func Missing(FieldValue? missing)
+ {
+ MissingValue = missing;
+ return Self;
+ }
+
public BoxplotAggregationDescriptor Script(Elastic.Clients.Elasticsearch.Script? script)
{
ScriptValue = script;
@@ -213,6 +241,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
JsonSerializer.Serialize(writer, FieldValue, options);
}
+ if (MissingValue is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, MissingValue, options);
+ }
+
if (ScriptValue is not null)
{
writer.WritePropertyName("script");
@@ -243,6 +277,8 @@ public BoxplotAggregationDescriptor() : base()
private Dictionary? MetaValue { get; set; }
+ private FieldValue? MissingValue { get; set; }
+
private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; }
public BoxplotAggregationDescriptor Compression(double? compression)
@@ -275,6 +311,12 @@ public BoxplotAggregationDescriptor Meta(Func,
return Self;
}
+ public BoxplotAggregationDescriptor Missing(FieldValue? missing)
+ {
+ MissingValue = missing;
+ return Self;
+ }
+
public BoxplotAggregationDescriptor Script(Elastic.Clients.Elasticsearch.Script? script)
{
ScriptValue = script;
@@ -298,6 +340,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
JsonSerializer.Serialize(writer, FieldValue, options);
}
+ if (MissingValue is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, MissingValue, options);
+ }
+
if (ScriptValue is not null)
{
writer.WritePropertyName("script");
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregation.g.cs
index 56f35b767b9..9ef2db49d93 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregation.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregation.g.cs
@@ -63,6 +63,18 @@ public override CardinalityAggregation Read(ref Utf8JsonReader reader, Type type
continue;
}
+ if (reader.ValueTextEquals("missing"))
+ {
+ reader.Read();
+ var value = JsonSerializer.Deserialize(ref reader, options);
+ if (value is not null)
+ {
+ agg.Missing = value;
+ }
+
+ continue;
+ }
+
if (reader.ValueTextEquals("precision_threshold"))
{
reader.Read();
@@ -138,6 +150,12 @@ public override void Write(Utf8JsonWriter writer, CardinalityAggregation value,
JsonSerializer.Serialize(writer, value.Field, options);
}
+ if (value.Missing is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, value.Missing, options);
+ }
+
if (value.PrecisionThreshold.HasValue)
{
writer.WritePropertyName("precision_threshold");
@@ -182,6 +200,8 @@ internal CardinalityAggregation()
public Dictionary? Meta { get; set; }
+ public FieldValue? Missing { get; set; }
+
public override string? Name { get; internal set; }
public int? PrecisionThreshold { get; set; }
@@ -204,6 +224,8 @@ public CardinalityAggregationDescriptor() : base()
private Dictionary? MetaValue { get; set; }
+ private FieldValue? MissingValue { get; set; }
+
private int? PrecisionThresholdValue { get; set; }
private bool? RehashValue { get; set; }
@@ -234,6 +256,12 @@ public CardinalityAggregationDescriptor Meta(Func Missing(FieldValue? missing)
+ {
+ MissingValue = missing;
+ return Self;
+ }
+
public CardinalityAggregationDescriptor PrecisionThreshold(int? precisionThreshold)
{
PrecisionThresholdValue = precisionThreshold;
@@ -269,6 +297,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
JsonSerializer.Serialize(writer, FieldValue, options);
}
+ if (MissingValue is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, MissingValue, options);
+ }
+
if (PrecisionThresholdValue.HasValue)
{
writer.WritePropertyName("precision_threshold");
@@ -311,6 +345,8 @@ public CardinalityAggregationDescriptor() : base()
private Dictionary? MetaValue { get; set; }
+ private FieldValue? MissingValue { get; set; }
+
private int? PrecisionThresholdValue { get; set; }
private bool? RehashValue { get; set; }
@@ -347,6 +383,12 @@ public CardinalityAggregationDescriptor Meta(Func? AfterKey { get; init; }
+ public Dictionary? AfterKey { get; init; }
[JsonInclude]
[JsonPropertyName("buckets")]
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs
index 3d5e6796d11..11f0eb6f346 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregation.g.cs
@@ -42,7 +42,7 @@ public override CompositeAggregation Read(ref Utf8JsonReader reader, Type typeTo
if (reader.ValueTextEquals("after"))
{
reader.Read();
- var value = JsonSerializer.Deserialize?>(ref reader, options);
+ var value = JsonSerializer.Deserialize?>(ref reader, options);
if (value is not null)
{
agg.After = value;
@@ -156,7 +156,7 @@ internal CompositeAggregation()
{
}
- public Dictionary? After { get; set; }
+ public Dictionary? After { get; set; }
public Elastic.Clients.Elasticsearch.Aggregations.AggregationDictionary? Aggregations { get; set; }
@@ -182,7 +182,7 @@ public CompositeAggregationDescriptor() : base()
private Action> AggregationsDescriptorAction { get; set; }
- private Dictionary? AfterValue { get; set; }
+ private Dictionary? AfterValue { get; set; }
private Dictionary? MetaValue { get; set; }
@@ -214,9 +214,9 @@ public CompositeAggregationDescriptor Aggregations(Action After(Func, FluentDictionary> selector)
+ public CompositeAggregationDescriptor After(Func, FluentDictionary> selector)
{
- AfterValue = selector?.Invoke(new FluentDictionary());
+ AfterValue = selector?.Invoke(new FluentDictionary());
return Self;
}
@@ -301,7 +301,7 @@ public CompositeAggregationDescriptor() : base()
private Action AggregationsDescriptorAction { get; set; }
- private Dictionary? AfterValue { get; set; }
+ private Dictionary? AfterValue { get; set; }
private Dictionary? MetaValue { get; set; }
@@ -333,9 +333,9 @@ public CompositeAggregationDescriptor Aggregations(Action, FluentDictionary> selector)
+ public CompositeAggregationDescriptor After(Func, FluentDictionary> selector)
{
- AfterValue = selector?.Invoke(new FluentDictionary());
+ AfterValue = selector?.Invoke(new FluentDictionary());
return Self;
}
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs
index 48cbff0ecd0..53a73e506d9 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs
@@ -37,7 +37,7 @@ public CompositeBucket(IReadOnlyDictionary backingDictionary
[JsonInclude]
[JsonPropertyName("key")]
- public Dictionary Key { get; init; }
+ public Dictionary Key { get; init; }
}
internal sealed class CompositeBucketConverter : JsonConverter
@@ -48,7 +48,7 @@ internal sealed class CompositeBucketConverter : JsonConverter
throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}.");
var subAggs = new Dictionary(); // TODO - Optimise this and only create if we need it.
long docCount = default;
- Dictionary key = default;
+ Dictionary key = default;
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
@@ -65,7 +65,7 @@ internal sealed class CompositeBucketConverter : JsonConverter
if (name.Equals("key", StringComparison.Ordinal))
{
- key = JsonSerializer.Deserialize>(ref reader, options);
+ key = JsonSerializer.Deserialize>(ref reader, options);
continue;
}
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs
index 76044f50ed7..cc902c6a90a 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregation.g.cs
@@ -63,6 +63,18 @@ public override DateRangeAggregation Read(ref Utf8JsonReader reader, Type typeTo
continue;
}
+ if (reader.ValueTextEquals("missing"))
+ {
+ reader.Read();
+ var value = JsonSerializer.Deserialize(ref reader, options);
+ if (value is not null)
+ {
+ agg.Missing = value;
+ }
+
+ continue;
+ }
+
if (reader.ValueTextEquals("ranges"))
{
reader.Read();
@@ -137,6 +149,12 @@ public override void Write(Utf8JsonWriter writer, DateRangeAggregation value, Js
writer.WriteStringValue(value.Format);
}
+ if (value.Missing is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, value.Missing, options);
+ }
+
if (value.Ranges is not null)
{
writer.WritePropertyName("ranges");
@@ -182,6 +200,8 @@ internal DateRangeAggregation()
public Dictionary? Meta { get; set; }
+ public FieldValue? Missing { get; set; }
+
public override string? Name { get; internal set; }
public IEnumerable? Ranges { get; set; }
@@ -208,6 +228,8 @@ public DateRangeAggregationDescriptor() : base()
private Dictionary? MetaValue { get; set; }
+ private FieldValue? MissingValue { get; set; }
+
private IEnumerable? RangesValue { get; set; }
private DateRangeExpressionDescriptor RangesDescriptor { get; set; }
@@ -266,6 +288,12 @@ public DateRangeAggregationDescriptor Meta(Func Missing(FieldValue? missing)
+ {
+ MissingValue = missing;
+ return Self;
+ }
+
public DateRangeAggregationDescriptor Ranges(IEnumerable? ranges)
{
RangesDescriptor = null;
@@ -325,6 +353,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
writer.WriteStringValue(FormatValue);
}
+ if (MissingValue is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, MissingValue, options);
+ }
+
if (RangesDescriptor is not null)
{
writer.WritePropertyName("ranges");
@@ -408,6 +442,8 @@ public DateRangeAggregationDescriptor() : base()
private Dictionary? MetaValue { get; set; }
+ private FieldValue? MissingValue { get; set; }
+
private IEnumerable? RangesValue { get; set; }
private DateRangeExpressionDescriptor RangesDescriptor { get; set; }
@@ -472,6 +508,12 @@ public DateRangeAggregationDescriptor Meta(Func
return Self;
}
+ public DateRangeAggregationDescriptor Missing(FieldValue? missing)
+ {
+ MissingValue = missing;
+ return Self;
+ }
+
public DateRangeAggregationDescriptor Ranges(IEnumerable? ranges)
{
RangesDescriptor = null;
@@ -531,6 +573,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
writer.WriteStringValue(FormatValue);
}
+ if (MissingValue is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, MissingValue, options);
+ }
+
if (RangesDescriptor is not null)
{
writer.WritePropertyName("ranges");
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs
index 02318caf277..01afe2492f0 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs
@@ -40,6 +40,6 @@ public sealed partial class DoubleTermsAggregate : IAggregate
[JsonInclude]
[JsonPropertyName("sum_other_doc_count")]
- public long SumOtherDocCount { get; init; }
+ public long? SumOtherDocCount { get; init; }
}
}
\ No newline at end of file
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs
index 070b6800714..c382b6602fe 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs
@@ -74,6 +74,14 @@ public sealed partial class ExtendedStatsAggregate : IAggregate
[JsonPropertyName("std_deviation_bounds_as_string")]
public Elastic.Clients.Elasticsearch.Aggregations.StandardDeviationBoundsAsString? StdDeviationBoundsAsString { get; init; }
+ [JsonInclude]
+ [JsonPropertyName("std_deviation_population")]
+ public double? StdDeviationPopulation { get; init; }
+
+ [JsonInclude]
+ [JsonPropertyName("std_deviation_sampling")]
+ public double? StdDeviationSampling { get; init; }
+
[JsonInclude]
[JsonPropertyName("sum")]
public double Sum { get; init; }
diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregation.g.cs
index 7a89c0c9246..6c296049e99 100644
--- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregation.g.cs
+++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregation.g.cs
@@ -63,6 +63,18 @@ public override ExtendedStatsAggregation Read(ref Utf8JsonReader reader, Type ty
continue;
}
+ if (reader.ValueTextEquals("missing"))
+ {
+ reader.Read();
+ var value = JsonSerializer.Deserialize(ref reader, options);
+ if (value is not null)
+ {
+ agg.Missing = value;
+ }
+
+ continue;
+ }
+
if (reader.ValueTextEquals("script"))
{
reader.Read();
@@ -126,6 +138,12 @@ public override void Write(Utf8JsonWriter writer, ExtendedStatsAggregation value
writer.WriteStringValue(value.Format);
}
+ if (value.Missing is not null)
+ {
+ writer.WritePropertyName("missing");
+ JsonSerializer.Serialize(writer, value.Missing, options);
+ }
+
if (value.Script is not null)
{
writer.WritePropertyName("script");
@@ -164,6 +182,8 @@ internal ExtendedStatsAggregation()
public Dictionary? Meta { get; set; }
+ public FieldValue? Missing { get; set; }
+
public override string? Name { get; internal set; }
public Elastic.Clients.Elasticsearch.Script? Script { get; set; }
@@ -184,6 +204,8 @@ public ExtendedStatsAggregationDescriptor() : base()
private Dictionary