Skip to content

Commit bc2f99d

Browse files
committed
made Score backward compatible
1 parent 36eb6c0 commit bc2f99d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Nest/Domain/Hit/Hit.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public interface IHit<out T> where T : class
1212
IFieldSelection<T> Fields { get; }
1313
T Source { get; }
1414
string Index { get; }
15-
double? Score { get; }
15+
double Score { get; }
1616
string Type { get; }
1717
string Version { get; }
1818
string Id { get; }
@@ -35,8 +35,12 @@ public class Hit<T> : IHit<T>
3535
public T Source { get; internal set; }
3636
[JsonProperty(PropertyName = "_index")]
3737
public string Index { get; internal set; }
38+
39+
//TODO in NEST 2.0 make the property itself double?
3840
[JsonProperty(PropertyName = "_score")]
39-
public double? Score { get; internal set; }
41+
internal double? _score { get; set; }
42+
public double Score { get { return _score.GetValueOrDefault(0); } }
43+
4044
[JsonProperty(PropertyName = "_type")]
4145
public string Type { get; internal set; }
4246
[JsonProperty(PropertyName = "_version")]

src/Nest/Resolvers/Converters/ConcreteTypeConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ internal static Type GetConcreteTypeUsingSelector<T>(
175175
hitDynamic.Fields = sel;
176176
hitDynamic.Source = d._source;
177177
hitDynamic.Index = d._index;
178-
hitDynamic.Score = (d._score is double) ? d._score : default(double);
178+
hitDynamic._score = (d._score is double) ? d._score : default(double);
179179
hitDynamic.Type = d._type;
180180
hitDynamic.Version = d._version;
181181
hitDynamic.Id = d._id;

0 commit comments

Comments
 (0)