33// See the LICENSE file in the project root for more information
44
55using System . Diagnostics ;
6+ using System . Runtime . Serialization ;
67using Elasticsearch . Net . Utf8Json ;
78
89namespace Nest
@@ -15,20 +16,37 @@ namespace Nest
1516 [ InterfaceDataContract ]
1617 public interface IRankFeaturesProperty : IProperty
1718 {
19+ /// <summary>
20+ /// Rank features that correlate negatively with the score should set <see cref="PositiveScoreImpact"/>
21+ /// to false (defaults to true). This will be used by the rank_features query to modify the scoring
22+ /// formula in such a way that the score decreases with the value of the feature instead of
23+ /// increasing.
24+ /// </summary>
25+ [ DataMember ( Name = "positive_score_impact" ) ]
26+ bool ? PositiveScoreImpact { get ; set ; }
1827 }
1928
2029 /// <inheritdoc cref="IRankFeaturesProperty" />
2130 public class RankFeaturesProperty : PropertyBase , IRankFeaturesProperty
2231 {
2332 public RankFeaturesProperty ( ) : base ( FieldType . RankFeatures ) { }
33+
34+ /// <inheritdoc />
35+ public bool ? PositiveScoreImpact { get ; set ; }
2436 }
2537
2638 /// <inheritdoc cref="IRankFeaturesProperty" />
27- [ DebuggerDisplay ( "{DebugDisplay}" ) ]
39+ [ DebuggerDisplay ( "{" + nameof ( DebugDisplay ) + " }") ]
2840 public class RankFeaturesPropertyDescriptor < T >
2941 : PropertyDescriptorBase < RankFeaturesPropertyDescriptor < T > , IRankFeaturesProperty , T > , IRankFeaturesProperty
3042 where T : class
3143 {
3244 public RankFeaturesPropertyDescriptor ( ) : base ( FieldType . RankFeatures ) { }
45+
46+ bool ? IRankFeaturesProperty . PositiveScoreImpact { get ; set ; }
47+
48+ /// <inheritdoc cref="IRankFeaturesProperty.PositiveScoreImpact" />
49+ public RankFeaturesPropertyDescriptor < T > PositiveScoreImpact ( bool ? positiveScoreImpact = true ) =>
50+ Assign ( positiveScoreImpact , ( a , v ) => a . PositiveScoreImpact = v ) ;
3351 }
3452}
0 commit comments