Skip to content

fix #994 known strings should be read using ReadAsString() to prevent da... #1191

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 1 commit into from
Jan 8, 2015
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
23 changes: 8 additions & 15 deletions src/Nest/Resolvers/Converters/Aggregations/AggregationConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ private IAggregation GetStatsAggregation(JsonReader reader, JsonSerializer seria

private IAggregation GetDateHistogramAggregation(JsonReader reader, JsonSerializer serializer)
{
reader.Read();
var keyAsString = reader.Value as string;
var keyAsString = reader.ReadAsString();
reader.Read(); reader.Read();
var key = (reader.Value as long?).GetValueOrDefault(0);
reader.Read(); reader.Read();
Expand All @@ -217,21 +216,18 @@ private IAggregation GetDateHistogramAggregation(JsonReader reader, JsonSerializ

private IAggregation GetKeyedBucketItem(JsonReader reader, JsonSerializer serializer)
{
reader.Read();
var key = reader.Value;
var key = reader.ReadAsString();
reader.Read();
var property = reader.Value as string;
if (property == "from" || property == "to")
return GetRangeAggregation(reader, serializer, key.ToString());

return GetRangeAggregation(reader, serializer, key);

var keyItem = new KeyItem();
keyItem.Key = key.ToString();
keyItem.Key = key;

if (property == "key_as_string")
{
reader.Read();
keyItem.KeyAsString = reader.Value.ToString();
keyItem.KeyAsString = reader.ReadAsString();
reader.Read();
}

Expand Down Expand Up @@ -407,18 +403,15 @@ public IAggregation GetRangeAggregation(JsonReader reader, JsonSerializer serial
reader.Read();
break;
case "key":
reader.Read();
key = reader.Value as string;
key = reader.ReadAsString();
reader.Read();
break;
case "from_as_string":
reader.Read();
fromAsString = reader.Value as string;
fromAsString = reader.ReadAsString();
reader.Read();
break;
case "to_as_string":
reader.Read();
toAsString = reader.Value as string;
toAsString = reader.ReadAsString();
reader.Read();
break;
case "doc_count":
Expand Down
Loading