Skip to content

Commit 7402ab3

Browse files
maesericharrusscam
authored andcommitted
Adding a new field to deserialize took as long, and marking the old one as obsolete.
1 parent bbd2ae4 commit 7402ab3

File tree

4 files changed

+83
-11
lines changed

4 files changed

+83
-11
lines changed

src/Nest/Document/Multiple/Bulk/BulkResponse.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
using System.Linq;
33
using System.Text;
44
using Newtonsoft.Json;
5+
using System;
56

67
namespace Nest
78
{
89
public interface IBulkResponse : IResponse
910
{
11+
[Obsolete(@"Took field is an Int but the value in the response can exced the max value for Int.
12+
If you use this field instead of TookAsLong the value can wrap around if it is too big.")]
1013
int Took { get; }
14+
long TookAsLong { get; }
1115
bool Errors { get; }
1216
IEnumerable<BulkResponseItemBase> Items { get; }
1317
IEnumerable<BulkResponseItemBase> ItemsWithErrors { get; }
@@ -26,7 +30,21 @@ protected override void DebugIsValid(StringBuilder sb)
2630
}
2731

2832
[JsonProperty("took")]
29-
public int Took { get; internal set; }
33+
public long TookAsLong { get; internal set;}
34+
35+
[Obsolete(@"Took field is an Int but the value in the response can exced the max value for Int.
36+
If you use this field instead of TookAsLong the value can wrap around if it is too big.")]
37+
public int Took
38+
{
39+
get
40+
{
41+
return unchecked((int)TookAsLong);
42+
}
43+
internal set
44+
{
45+
TookAsLong = value;
46+
}
47+
}
3048

3149
[JsonProperty("errors")]
3250
public bool Errors { get; internal set; }

src/Nest/Document/Single/TermVectors/TermVectorsResponse.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using System;
34

45
namespace Nest
56
{
@@ -10,7 +11,10 @@ public interface ITermVectorsResponse : IResponse
1011
string Id { get; }
1112
long Version { get; }
1213
bool Found { get; }
14+
[Obsolete(@"Took field is an Int but the value in the response can exced the max value for Int.
15+
If you use this field instead of TookAsLong the value can wrap around if it is too big.")]
1316
int Took { get; }
17+
long TookAsLong { get; }
1418
IDictionary<string, TermVector> TermVectors { get; }
1519
}
1620

@@ -33,7 +37,21 @@ public class TermVectorsResponse : ResponseBase, ITermVectorsResponse
3337
public bool Found { get; internal set; }
3438

3539
[JsonProperty(PropertyName = "took")]
36-
public int Took { get; internal set; }
40+
public long TookAsLong { get; internal set; }
41+
42+
[Obsolete(@"Took field is an Int but the value in the response can exced the max value for Int.
43+
If you use this field instead of TookAsLong the value can wrap around if it is too big.")]
44+
public int Took
45+
{
46+
get
47+
{
48+
return unchecked((int)TookAsLong);
49+
}
50+
internal set
51+
{
52+
TookAsLong = value;
53+
}
54+
}
3755

3856
[JsonProperty("term_vectors")]
3957
public IDictionary<string, TermVector> TermVectors { get; internal set; } = new Dictionary<string, TermVector>();

src/Nest/Search/Percolator/Percolate/PercolateResponse.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
using System.Collections.Generic;
22
using Elasticsearch.Net;
33
using Newtonsoft.Json;
4-
4+
using System;
5+
56
namespace Nest
67
{
78
public interface IPercolateCountResponse : IResponse
89
{
9-
int Took { get; }
10+
[Obsolete(@"Took field is an Int but the value in the response can exced the max value for Int.
11+
If you use this field instead of TookAsLong the value can wrap around if it is too big.")]
12+
int Took { get; }
13+
long TookAsLong { get; }
1014
long Total { get; }
1115
}
1216

@@ -18,15 +22,29 @@ public interface IPercolateResponse : IPercolateCountResponse
1822
[JsonObject]
1923
public class PercolateCountResponse : ResponseBase, IPercolateCountResponse
2024
{
21-
[JsonProperty(PropertyName = "took")]
22-
public int Took { get; internal set; }
25+
[JsonProperty("took")]
26+
public long TookAsLong { get; internal set; }
27+
28+
[Obsolete(@"Took field is an Int but the value in the response can exced the max value for Int.
29+
If you use this field instead of TookAsLong the value can wrap around if it is too big.")]
30+
public int Took
31+
{
32+
get
33+
{
34+
return unchecked((int)TookAsLong);
35+
}
36+
internal set
37+
{
38+
TookAsLong = value;
39+
}
40+
}
2341

2442
[JsonProperty(PropertyName = "total")]
2543
public long Total { get; internal set; }
26-
44+
2745
[JsonProperty(PropertyName = "_shards")]
2846
public ShardsMetaData Shards { get; internal set; }
29-
47+
3048
/// <summary>
3149
/// The individual error for separate requests on the _mpercolate API
3250
/// </summary>
@@ -59,4 +77,4 @@ public class PercolatorMatch
5977
public double Score { get; set; }
6078
}
6179

62-
}
80+
}

src/Nest/Search/Search/SearchResponse.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ public interface ISearchResponse<T> : IResponse where T : class
1414
Profile Profile { get; }
1515
AggregationsHelper Aggs { get; }
1616
IDictionary<string, Suggest[]> Suggest { get; }
17+
18+
[Obsolete(@"Took field is an Int but the value in the response can exced the max value for Int.
19+
If you use this field instead of TookAsLong the value can wrap around if it is too big.")]
1720
int Took { get; }
21+
long TookAsLong { get; }
1822
bool TimedOut { get; }
1923
bool TerminatedEarly { get; }
2024
string ScrollId { get; }
@@ -64,8 +68,22 @@ public class SearchResponse<T> : ResponseBase, ISearchResponse<T> where T : clas
6468
[JsonProperty(PropertyName = "suggest")]
6569
public IDictionary<string, Suggest[]> Suggest { get; internal set; }
6670

67-
[JsonProperty(PropertyName = "took")]
68-
public int Took { get; internal set; }
71+
[JsonProperty("took")]
72+
public long TookAsLong { get; internal set; }
73+
74+
[Obsolete(@"Took field is an Int but the value in the response can exced the max value for Int.
75+
If you use this field instead of TookAsLong the value can wrap around if it is too big.")]
76+
public int Took
77+
{
78+
get
79+
{
80+
return unchecked((int)TookAsLong);
81+
}
82+
internal set
83+
{
84+
TookAsLong = value;
85+
}
86+
}
6987

7088
[JsonProperty("timed_out")]
7189
public bool TimedOut { get; internal set; }

0 commit comments

Comments
 (0)