@@ -54,6 +54,13 @@ public RankFeatureQueryDescriptor<T> Logarithm(Func<RankFeatureLogarithmFunction
5454 /// <inheritdoc cref="IRankFeatureSigmoidFunction"/>
5555 public RankFeatureQueryDescriptor < T > Sigmoid ( Func < RankFeatureSigmoidFunctionDescriptor , IRankFeatureSigmoidFunction > selector ) =>
5656 Assign ( selector , ( a , v ) => a . Function = v ? . Invoke ( new RankFeatureSigmoidFunctionDescriptor ( ) ) ) ;
57+
58+ /// <inheritdoc cref="IRankFeatureLinearFunction"/>
59+ public RankFeatureQueryDescriptor < T > Linear ( )
60+ {
61+ Self . Function = new RankFeatureLinearFunction ( ) ;
62+ return this ;
63+ }
5764 }
5865
5966 /// <summary>
@@ -162,6 +169,24 @@ public class RankFeatureSigmoidFunctionDescriptor
162169 public RankFeatureSigmoidFunctionDescriptor Pivot ( float pivot ) => Assign ( pivot , ( a , v ) => a . Pivot = v ) ;
163170 }
164171
172+ /// <summary>
173+ /// Gives a score equal to the indexed value of S, where S is the value of the rank feature field.
174+ ///
175+ /// If a rank feature field is indexed with "positive_score_impact": true, its indexed value is equal to S and rounded to preserve
176+ /// only 9 significant bits for the precision.
177+ ///
178+ /// If a rank feature field is indexed with "positive_score_impact": false, its indexed value is equal to 1/S and rounded to
179+ /// preserve only 9 significant bits for the precision.
180+ /// </summary>
181+ public interface IRankFeatureLinearFunction : IRankFeatureFunction
182+ {
183+ }
184+
185+ /// <inheritdoc cref="IRankFeatureLinearFunction" />
186+ public class RankFeatureLinearFunction : IRankFeatureLinearFunction
187+ {
188+ }
189+
165190 internal class RankFeatureQueryFormatter : IJsonFormatter < IRankFeatureQuery >
166191 {
167192 public void Serialize ( ref JsonWriter writer , IRankFeatureQuery value , IJsonFormatterResolver formatterResolver )
@@ -206,6 +231,9 @@ public void Serialize(ref JsonWriter writer, IRankFeatureQuery value, IJsonForma
206231 case IRankFeatureLogarithmFunction log :
207232 SerializeScoreFunction ( ref writer , "log" , log , formatterResolver ) ;
208233 break ;
234+ case IRankFeatureLinearFunction log :
235+ SerializeScoreFunction ( ref writer , "linear" , log , formatterResolver ) ;
236+ break ;
209237 }
210238 }
211239
@@ -232,7 +260,8 @@ private static IRankFeatureFunction DeserializeScoreFunction<TScoreFunction>(ref
232260 { "field" , 2 } ,
233261 { "saturation" , 3 } ,
234262 { "log" , 4 } ,
235- { "sigmoid" , 5 }
263+ { "sigmoid" , 5 } ,
264+ { "linear" , 6 }
236265 } ;
237266
238267 public IRankFeatureQuery Deserialize ( ref JsonReader reader , IJsonFormatterResolver formatterResolver )
@@ -266,6 +295,9 @@ public IRankFeatureQuery Deserialize(ref JsonReader reader, IJsonFormatterResolv
266295 case 5 :
267296 query . Function = DeserializeScoreFunction < RankFeatureSigmoidFunction > ( ref reader , formatterResolver ) ;
268297 break ;
298+ case 6 :
299+ query . Function = DeserializeScoreFunction < RankFeatureLinearFunction > ( ref reader , formatterResolver ) ;
300+ break ;
269301 }
270302 }
271303 else
0 commit comments