Skip to content

Commit 7fe138e

Browse files
committed
little tidy up
1 parent ae2a49a commit 7fe138e

File tree

7 files changed

+26
-21
lines changed

7 files changed

+26
-21
lines changed

src/Benchmarking/project.lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7811,7 +7811,7 @@
78117811
"runtime.win7.System.Net.Requests/4.0.11-beta-23516": {
78127812
"type": "package",
78137813
"serviceable": true,
7814-
"sha512": "HI99nCEekL4SNvkLmpqkOE0PuEF5B6xyDcnJesdjo06BrGYH3QCvqJt2VmzBVe6hDSo6FnGOlhMvLdCUpDXiXA==",
7814+
"sha512": "mqWBQUhXhzkiwb+zVUuKg+wswJUsnQtZkFtz6eISw8vWNXA9i2jkzYjU3pjjIVmtdopnhle9YaS4a/w4OuWGLw==",
78157815
"files": [
78167816
"ref/dotnet/_._",
78177817
"runtime.win7.System.Net.Requests.4.0.11-beta-23516.nupkg",

src/Elasticsearch.Net/project.lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@
17391739
"runtime.win7.System.Net.Requests/4.0.11-beta-23516": {
17401740
"type": "package",
17411741
"serviceable": true,
1742-
"sha512": "HI99nCEekL4SNvkLmpqkOE0PuEF5B6xyDcnJesdjo06BrGYH3QCvqJt2VmzBVe6hDSo6FnGOlhMvLdCUpDXiXA==",
1742+
"sha512": "mqWBQUhXhzkiwb+zVUuKg+wswJUsnQtZkFtz6eISw8vWNXA9i2jkzYjU3pjjIVmtdopnhle9YaS4a/w4OuWGLw==",
17431743
"files": [
17441744
"ref/dotnet/_._",
17451745
"runtime.win7.System.Net.Requests.4.0.11-beta-23516.nupkg",

src/Nest/Aggregations/AggregateJsonConverter.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Nest
1010
{
1111
internal class AggregateJsonConverter : JsonConverter
1212
{
13-
private static Regex _numeric = new Regex(@"^[\d.]+(\.[\d.]+)?$");
13+
private static readonly Regex _numeric = new Regex(@"^[\d.]+(\.[\d.]+)?$");
1414

1515
public override bool CanWrite => false;
1616

@@ -40,6 +40,12 @@ private IAggregate ReadAggregation(JsonReader reader, JsonSerializer serializer)
4040

4141
var meta = (property == "meta") ? GetMetadata(reader) : null;
4242

43+
if (result != null)
44+
{
45+
result.Meta = meta;
46+
return result;
47+
}
48+
4349
property = reader.Value as string;
4450

4551
switch (property)
@@ -148,16 +154,15 @@ private IAggregate GetGeoBoundsMetric(JsonReader reader, JsonSerializer serializ
148154
return null;
149155
var geoBoundsMetric = new GeoBoundsAggregate();
150156
JToken topLeftToken;
151-
o.TryGetValue("top_left", out topLeftToken);
152-
if (topLeftToken != null)
157+
if (o.TryGetValue("top_left", out topLeftToken) && topLeftToken != null)
153158
{
154159
var topLeft = topLeftToken.ToObject<LatLon>();
155160
if (topLeft != null)
156161
geoBoundsMetric.Bounds.TopLeft = topLeft;
157162
}
163+
158164
JToken bottomRightToken;
159-
o.TryGetValue("bottom_right", out bottomRightToken);
160-
if (bottomRightToken != null)
165+
if (o.TryGetValue("bottom_right", out bottomRightToken) && bottomRightToken != null)
161166
{
162167
var bottomRight = bottomRightToken.ToObject<LatLon>();
163168
if (bottomRight != null)
@@ -204,9 +209,7 @@ private IAggregate GetDocCountBucket(JsonReader reader, JsonSerializer serialize
204209
var docCount = (reader.Value as long?).GetValueOrDefault(0);
205210
var bucket = new SingleBucketAggregate { DocCount = docCount };
206211
reader.Read();
207-
if (reader.TokenType == JsonToken.PropertyName
208-
&& ((string)reader.Value) == "buckets"
209-
)
212+
if (reader.TokenType == JsonToken.PropertyName && (string)reader.Value == "buckets")
210213
{
211214
var b = this.GetBucket(reader, serializer) as BucketAggregateData;
212215
return new BucketAggregateData
@@ -489,17 +492,18 @@ public IBucketItem GetRangeItem(JsonReader reader, JsonSerializer serializer, st
489492
break;
490493
}
491494
}
495+
492496
var bucket = new RangeItem
493497
{
494498
Key = key,
495499
From = fromDouble,
496500
To = toDouble,
497501
DocCount = docCount.GetValueOrDefault(),
498502
FromAsString = fromAsString,
499-
ToAsString = toAsString
503+
ToAsString = toAsString,
504+
Aggregations = this.GetNestedAggregations(reader, serializer)
500505
};
501506

502-
bucket.Aggregations = this.GetNestedAggregations(reader, serializer);
503507
return bucket;
504508
}
505509

@@ -526,8 +530,7 @@ private IBucketItem GetKeyedBucketItem(JsonReader reader, JsonSerializer seriali
526530
if (property == "from" || property == "to")
527531
return GetRangeItem(reader, serializer, key);
528532

529-
var keyItem = new KeyedBucketItem();
530-
keyItem.Key = key;
533+
var keyItem = new KeyedBucketItem {Key = key};
531534

532535
if (property == "key_as_string")
533536
{
@@ -574,8 +577,10 @@ private IBucketItem GetSignificantTermItem(JsonReader reader, JsonSerializer ser
574577
private IBucketItem GetFiltersBucketItem(JsonReader reader, JsonSerializer serializer)
575578
{
576579
reader.Read();
577-
var filtersBucketItem = new FiltersBucketItem();
578-
filtersBucketItem.DocCount = (reader.Value as long?).GetValueOrDefault(0);
580+
var filtersBucketItem = new FiltersBucketItem
581+
{
582+
DocCount = (reader.Value as long?).GetValueOrDefault(0)
583+
};
579584
reader.Read();
580585
filtersBucketItem.Aggregations = this.GetNestedAggregations(reader, serializer);
581586
return filtersBucketItem;

src/Nest/Aggregations/AggregationsHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Nest
55
{
66
public class AggregationsHelper
77
{
8-
public IDictionary<string, IAggregate> Aggregations { get; internal protected set; }
8+
public IDictionary<string, IAggregate> Aggregations { get; protected internal set; }
99

1010
public AggregationsHelper() { }
1111

src/Nest/Aggregations/Bucket/BucketAggregate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace Nest
55
{
66
public abstract class BucketAggregateBase : AggregationsHelper, IAggregate
77
{
8-
public BucketAggregateBase() { }
9-
public BucketAggregateBase(IDictionary<string, IAggregate> aggregations) : base(aggregations) { }
8+
protected BucketAggregateBase() { }
9+
protected BucketAggregateBase(IDictionary<string, IAggregate> aggregations) : base(aggregations) { }
1010

1111
public IDictionary<string, object> Meta { get; set; }
1212
}

src/Nest/project.lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@
20592059
"runtime.win7.System.Net.Requests/4.0.11-beta-23516": {
20602060
"type": "package",
20612061
"serviceable": true,
2062-
"sha512": "HI99nCEekL4SNvkLmpqkOE0PuEF5B6xyDcnJesdjo06BrGYH3QCvqJt2VmzBVe6hDSo6FnGOlhMvLdCUpDXiXA==",
2062+
"sha512": "mqWBQUhXhzkiwb+zVUuKg+wswJUsnQtZkFtz6eISw8vWNXA9i2jkzYjU3pjjIVmtdopnhle9YaS4a/w4OuWGLw==",
20632063
"files": [
20642064
"ref/dotnet/_._",
20652065
"runtime.win7.System.Net.Requests.4.0.11-beta-23516.nupkg",

src/Tests/project.lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6406,7 +6406,7 @@
64066406
"runtime.win7.System.Net.Requests/4.0.11-beta-23516": {
64076407
"type": "package",
64086408
"serviceable": true,
6409-
"sha512": "HI99nCEekL4SNvkLmpqkOE0PuEF5B6xyDcnJesdjo06BrGYH3QCvqJt2VmzBVe6hDSo6FnGOlhMvLdCUpDXiXA==",
6409+
"sha512": "mqWBQUhXhzkiwb+zVUuKg+wswJUsnQtZkFtz6eISw8vWNXA9i2jkzYjU3pjjIVmtdopnhle9YaS4a/w4OuWGLw==",
64106410
"files": [
64116411
"ref/dotnet/_._",
64126412
"runtime.win7.System.Net.Requests.4.0.11-beta-23516.nupkg",

0 commit comments

Comments
 (0)