Skip to content

Initial support for additional properties behaviour #6604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Elastic.Clients.Elasticsearch/Serialization/Stringified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ namespace Elastic.Clients.Elasticsearch;

internal sealed class StringifiedLongConverter : JsonConverter<long?>
{
public override long? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override long? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedLong(ref reader);

public override void Write(Utf8JsonWriter writer, long? value, JsonSerializerOptions options) => writer.WriteNumberValue(value.Value);

public static long ReadStringifiedLong(ref Utf8JsonReader reader)
{
if (reader.TokenType == JsonTokenType.PropertyName)
reader.Read();

if (reader.TokenType == JsonTokenType.String)
{
var longString = reader.GetString();
Expand All @@ -25,8 +32,6 @@ internal sealed class StringifiedLongConverter : JsonConverter<long?>
}

return reader.GetInt64();
}


public override void Write(Utf8JsonWriter writer, long? value, JsonSerializerOptions options) => writer.WriteNumberValue(value.Value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public override AdjacencyMatrixAggregation Read(ref Utf8JsonReader reader, Type
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -120,8 +119,6 @@ public AdjacencyMatrixAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("filters")]
public Dictionary<string, Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer>? Filters { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ public override AutoDateHistogramAggregation Read(ref Utf8JsonReader reader, Typ
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -264,40 +263,22 @@ public AutoDateHistogramAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("buckets")]
public int? Buckets { get; set; }

[JsonInclude]
[JsonPropertyName("field")]
public Elastic.Clients.Elasticsearch.Field? Field { get; set; }

[JsonInclude]
[JsonPropertyName("format")]
public string? Format { get; set; }

[JsonInclude]
[JsonPropertyName("minimum_interval")]
public Elastic.Clients.Elasticsearch.Aggregations.MinimumInterval? MinimumInterval { get; set; }

[JsonInclude]
[JsonPropertyName("missing")]
public DateTimeOffset? Missing { get; set; }

[JsonInclude]
[JsonPropertyName("offset")]
public string? Offset { get; set; }

[JsonInclude]
[JsonPropertyName("params")]
public Dictionary<string, object>? Params { get; set; }

[JsonInclude]
[JsonPropertyName("script")]
public ScriptBase? Script { get; set; }

[JsonInclude]
[JsonPropertyName("time_zone")]
public string? TimeZone { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public override AverageAggregation Read(ref Utf8JsonReader reader, Type typeToCo
}
}

reader.Read();
return agg;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public override BoxplotAggregation Read(ref Utf8JsonReader reader, Type typeToCo
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -140,8 +139,6 @@ public BoxplotAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("compression")]
public double? Compression { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public override CardinalityAggregation Read(ref Utf8JsonReader reader, Type type
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -158,12 +157,8 @@ public CardinalityAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("precision_threshold")]
public int? PrecisionThreshold { get; set; }

[JsonInclude]
[JsonPropertyName("rehash")]
public bool? Rehash { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public override ChildrenAggregation Read(ref Utf8JsonReader reader, Type typeToC
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -120,8 +119,6 @@ public ChildrenAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("type")]
public string? Type { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public override CompositeAggregation Read(ref Utf8JsonReader reader, Type typeTo
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -156,16 +155,10 @@ public CompositeAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("after")]
public Dictionary<string, object>? After { get; set; }

[JsonInclude]
[JsonPropertyName("size")]
public int? Size { get; set; }

[JsonInclude]
[JsonPropertyName("sources")]
public IEnumerable<Dictionary<string, Elastic.Clients.Elasticsearch.Aggregations.CompositeAggregationSource>>? Sources { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public override CumulativeCardinalityAggregation Read(ref Utf8JsonReader reader,
}
}

reader.Read();
return agg;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ public override DateHistogramAggregation Read(ref Utf8JsonReader reader, Type ty
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -300,49 +299,27 @@ public DateHistogramAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("calendar_interval")]
public Elastic.Clients.Elasticsearch.Aggregations.CalendarInterval? CalendarInterval { get; set; }

[JsonInclude]
[JsonPropertyName("field")]
public Elastic.Clients.Elasticsearch.Field? Field { get; set; }

[JsonInclude]
[JsonPropertyName("fixed_interval")]
public Elastic.Clients.Elasticsearch.Duration? FixedInterval { get; set; }

[JsonInclude]
[JsonPropertyName("format")]
public string? Format { get; set; }

[JsonInclude]
[JsonPropertyName("min_doc_count")]
public int? MinDocCount { get; set; }

[JsonInclude]
[JsonPropertyName("missing")]
public DateTimeOffset? Missing { get; set; }

[JsonInclude]
[JsonPropertyName("offset")]
public Elastic.Clients.Elasticsearch.Duration? Offset { get; set; }

[JsonInclude]
[JsonPropertyName("order")]
[JsonConverter(typeof(AggregateOrderConverter))]
public IEnumerable<KeyValuePair<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.SortOrder>>? Order { get; set; }

[JsonInclude]
[JsonPropertyName("params")]
public Dictionary<string, object>? Params { get; set; }

[JsonInclude]
[JsonPropertyName("script")]
public ScriptBase? Script { get; set; }

[JsonInclude]
[JsonPropertyName("time_zone")]
public string? TimeZone { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public override DateRangeAggregation Read(ref Utf8JsonReader reader, Type typeTo
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -174,20 +173,12 @@ public DateRangeAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("field")]
public Elastic.Clients.Elasticsearch.Field? Field { get; set; }

[JsonInclude]
[JsonPropertyName("format")]
public string? Format { get; set; }

[JsonInclude]
[JsonPropertyName("ranges")]
public IEnumerable<Elastic.Clients.Elasticsearch.Aggregations.DateRangeExpression>? Ranges { get; set; }

[JsonInclude]
[JsonPropertyName("time_zone")]
public string? TimeZone { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public override DerivativeAggregation Read(ref Utf8JsonReader reader, Type typeT
}
}

reader.Read();
return agg;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public override ExtendedStatsAggregation Read(ref Utf8JsonReader reader, Type ty
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -158,8 +157,6 @@ public ExtendedStatsAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("sigma")]
public double? Sigma { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public override ExtendedStatsBucketAggregation Read(ref Utf8JsonReader reader, T
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -157,8 +156,6 @@ public ExtendedStatsBucketAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("sigma")]
public double? Sigma { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public override FiltersAggregation Read(ref Utf8JsonReader reader, Type typeToCo
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -156,16 +155,10 @@ public FiltersAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("filters")]
public Elastic.Clients.Elasticsearch.Aggregations.Buckets<Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer>? Filters { get; set; }

[JsonInclude]
[JsonPropertyName("other_bucket")]
public bool? OtherBucket { get; set; }

[JsonInclude]
[JsonPropertyName("other_bucket_key")]
public string? OtherBucketKey { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public override GlobalAggregation Read(ref Utf8JsonReader reader, Type typeToCon
}
}

reader.Read();
return agg;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public override HistogramAggregation Read(ref Utf8JsonReader reader, Type typeTo
}
}

reader.Read();
return agg;
}

Expand Down Expand Up @@ -246,37 +245,21 @@ public HistogramAggregation(string name) : base(name)
{
}

[JsonInclude]
[JsonPropertyName("field")]
public Elastic.Clients.Elasticsearch.Field? Field { get; set; }

[JsonInclude]
[JsonPropertyName("format")]
public string? Format { get; set; }

[JsonInclude]
[JsonPropertyName("interval")]
public double? Interval { get; set; }

[JsonInclude]
[JsonPropertyName("min_doc_count")]
public int? MinDocCount { get; set; }

[JsonInclude]
[JsonPropertyName("missing")]
public double? Missing { get; set; }

[JsonInclude]
[JsonPropertyName("offset")]
public double? Offset { get; set; }

[JsonInclude]
[JsonPropertyName("order")]
[JsonConverter(typeof(AggregateOrderConverter))]
public IEnumerable<KeyValuePair<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.SortOrder>>? Order { get; set; }

[JsonInclude]
[JsonPropertyName("script")]
public ScriptBase? Script { get; set; }
}

Expand Down
Loading