Skip to content
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
1 change: 1 addition & 0 deletions src/Nest/Nest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@
<Compile Include="Search\Explain\Explanation.cs" />
<Compile Include="Search\Explain\ExplanationDetail.cs" />
<Compile Include="Search\FieldStats\ElasticClient-FieldStats.cs" />
<Compile Include="Search\FieldStats\FieldMinMaxValueJsonConverter.cs" />
<Compile Include="Search\FieldStats\FieldStatsRequest.cs" />
<Compile Include="Search\FieldStats\FieldStatsResponse.cs" />
<Compile Include="Search\FieldStats\IndexConstraint.cs" />
Expand Down
28 changes: 28 additions & 0 deletions src/Nest/Search/FieldStats/FieldMinMaxValueJsonConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using Newtonsoft.Json;

namespace Nest
{
internal class FieldMinMaxValueJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType) => true;
public override bool CanWrite => false;
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { }

public override bool CanRead => true;
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.StartObject || reader.TokenType == JsonToken.StartArray)
{
var depth = reader.Depth;
do
{
reader.Read();
} while (reader.Depth >= depth && reader.TokenType != JsonToken.EndObject);
return null;
}
return reader.Value.ToString();
}

}
}
21 changes: 21 additions & 0 deletions src/Nest/Search/FieldStats/FieldStatsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,31 @@ public class FieldStatsField
[JsonProperty("aggregatable")]
public bool Aggregatable { get; internal set; }

/// <summary>
/// Returns the min value of a field. In NEST 5.x this is always
/// returned as a string which does not work for geo_point and geo_shape
/// typed fields which return an object here since Elasticsearch 5.3
/// so in 5.x this is always null for geo_point and geo_shape. Please use <see cref="MinValueAsString"/>
/// </summary>
[JsonProperty("min_value")]
[JsonConverter(typeof(FieldMinMaxValueJsonConverter))]
public string MinValue { get; internal set; }

[JsonProperty("min_value_as_string")]
public string MinValueAsString { get; internal set; }

/// <summary>
/// Returns the max value of a field. In NEST 5.x this is always
/// returned as a string which does not work for geo_point and geo_shape
/// typed fields which return an object here since Elasticsearch 5.3
/// so in 5.x this is always null for geo_point and geo_shape. Please use <see cref="MaxValueAsString"/>
/// </summary>
[JsonProperty("max_value")]
[JsonConverter(typeof(FieldMinMaxValueJsonConverter))]
public string MaxValue { get; internal set; }

[JsonProperty("max_value_as_string")]
public string MaxValueAsString { get; internal set; }

}
}
2 changes: 1 addition & 1 deletion src/Tests/tests.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# tracked by git).

# mode either u (unit test), i (integration test) or m (mixed mode)
mode: u
mode: i
# the elasticsearch version that should be started
# Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype
elasticsearch_version: 5.3.0-SNAPSHOT
Expand Down