diff --git a/src/Nest/Mapping/Types/Core/RankFeatures/RankFeaturesAttribute.cs b/src/Nest/Mapping/Types/Core/RankFeatures/RankFeaturesAttribute.cs
index 6afd7af84f4..993ea7cc9b9 100644
--- a/src/Nest/Mapping/Types/Core/RankFeatures/RankFeaturesAttribute.cs
+++ b/src/Nest/Mapping/Types/Core/RankFeatures/RankFeaturesAttribute.cs
@@ -8,5 +8,16 @@ namespace Nest
public class RankFeaturesAttribute : ElasticsearchPropertyAttributeBase, IRankFeaturesProperty
{
public RankFeaturesAttribute() : base(FieldType.RankFeatures) { }
+
+ private IRankFeaturesProperty Self => this;
+
+ ///
+ public bool PositiveScoreImpact
+ {
+ get => Self.PositiveScoreImpact.GetValueOrDefault(true);
+ set => Self.PositiveScoreImpact = value;
+ }
+
+ bool? IRankFeaturesProperty.PositiveScoreImpact { get; set; }
}
}
diff --git a/src/Nest/Mapping/Types/Core/RankFeatures/RankFeaturesProperty.cs b/src/Nest/Mapping/Types/Core/RankFeatures/RankFeaturesProperty.cs
index a871c7edae6..42edfdb1fa7 100644
--- a/src/Nest/Mapping/Types/Core/RankFeatures/RankFeaturesProperty.cs
+++ b/src/Nest/Mapping/Types/Core/RankFeatures/RankFeaturesProperty.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information
using System.Diagnostics;
+using System.Runtime.Serialization;
using Elasticsearch.Net.Utf8Json;
namespace Nest
@@ -15,20 +16,37 @@ namespace Nest
[InterfaceDataContract]
public interface IRankFeaturesProperty : IProperty
{
+ ///
+ /// Rank features that correlate negatively with the score should set
+ /// to false (defaults to true). This will be used by the rank_features query to modify the scoring
+ /// formula in such a way that the score decreases with the value of the feature instead of
+ /// increasing.
+ ///
+ [DataMember(Name = "positive_score_impact")]
+ bool? PositiveScoreImpact { get; set; }
}
///
public class RankFeaturesProperty : PropertyBase, IRankFeaturesProperty
{
public RankFeaturesProperty() : base(FieldType.RankFeatures) { }
+
+ ///
+ public bool? PositiveScoreImpact { get; set; }
}
///
- [DebuggerDisplay("{DebugDisplay}")]
+ [DebuggerDisplay("{" + nameof(DebugDisplay) + "}")]
public class RankFeaturesPropertyDescriptor
: PropertyDescriptorBase, IRankFeaturesProperty, T>, IRankFeaturesProperty
where T : class
{
public RankFeaturesPropertyDescriptor() : base(FieldType.RankFeatures) { }
+
+ bool? IRankFeaturesProperty.PositiveScoreImpact { get; set; }
+
+ ///
+ public RankFeaturesPropertyDescriptor PositiveScoreImpact(bool? positiveScoreImpact = true) =>
+ Assign(positiveScoreImpact, (a, v) => a.PositiveScoreImpact = v);
}
}