@@ -56,6 +56,13 @@ public RankFeatureQueryDescriptor<T> Logarithm(Func<RankFeatureLogarithmFunction
5656 /// <inheritdoc cref="IRankFeatureSigmoidFunction"/>
5757 public RankFeatureQueryDescriptor < T > Sigmoid ( Func < RankFeatureSigmoidFunctionDescriptor , IRankFeatureSigmoidFunction > selector ) =>
5858 Assign ( selector , ( a , v ) => a . Function = v ? . Invoke ( new RankFeatureSigmoidFunctionDescriptor ( ) ) ) ;
59+
60+ /// <inheritdoc cref="IRankFeatureLinearFunction"/>
61+ public RankFeatureQueryDescriptor < T > Linear ( )
62+ {
63+ Self . Function = new RankFeatureLinearFunction ( ) ;
64+ return this ;
65+ }
5966 }
6067
6168 /// <summary>
@@ -164,6 +171,24 @@ public class RankFeatureSigmoidFunctionDescriptor
164171 public RankFeatureSigmoidFunctionDescriptor Pivot ( float pivot ) => Assign ( pivot , ( a , v ) => a . Pivot = v ) ;
165172 }
166173
174+ /// <summary>
175+ /// Gives a score equal to the indexed value of S, where S is the value of the rank feature field.
176+ ///
177+ /// If a rank feature field is indexed with "positive_score_impact": true, its indexed value is equal to S and rounded to preserve
178+ /// only 9 significant bits for the precision.
179+ ///
180+ /// If a rank feature field is indexed with "positive_score_impact": false, its indexed value is equal to 1/S and rounded to
181+ /// preserve only 9 significant bits for the precision.
182+ /// </summary>
183+ public interface IRankFeatureLinearFunction : IRankFeatureFunction
184+ {
185+ }
186+
187+ /// <inheritdoc cref="IRankFeatureLinearFunction" />
188+ public class RankFeatureLinearFunction : IRankFeatureLinearFunction
189+ {
190+ }
191+
167192 internal class RankFeatureQueryFormatter : IJsonFormatter < IRankFeatureQuery >
168193 {
169194 public void Serialize ( ref JsonWriter writer , IRankFeatureQuery value , IJsonFormatterResolver formatterResolver )
@@ -208,6 +233,9 @@ public void Serialize(ref JsonWriter writer, IRankFeatureQuery value, IJsonForma
208233 case IRankFeatureLogarithmFunction log :
209234 SerializeScoreFunction ( ref writer , "log" , log , formatterResolver ) ;
210235 break ;
236+ case IRankFeatureLinearFunction log :
237+ SerializeScoreFunction ( ref writer , "linear" , log , formatterResolver ) ;
238+ break ;
211239 }
212240 }
213241
@@ -234,7 +262,8 @@ private static IRankFeatureFunction DeserializeScoreFunction<TScoreFunction>(ref
234262 { "field" , 2 } ,
235263 { "saturation" , 3 } ,
236264 { "log" , 4 } ,
237- { "sigmoid" , 5 }
265+ { "sigmoid" , 5 } ,
266+ { "linear" , 6 }
238267 } ;
239268
240269 public IRankFeatureQuery Deserialize ( ref JsonReader reader , IJsonFormatterResolver formatterResolver )
@@ -268,6 +297,9 @@ public IRankFeatureQuery Deserialize(ref JsonReader reader, IJsonFormatterResolv
268297 case 5 :
269298 query . Function = DeserializeScoreFunction < RankFeatureSigmoidFunction > ( ref reader , formatterResolver ) ;
270299 break ;
300+ case 6 :
301+ query . Function = DeserializeScoreFunction < RankFeatureLinearFunction > ( ref reader , formatterResolver ) ;
302+ break ;
271303 }
272304 }
273305 else
0 commit comments