@@ -56,6 +56,13 @@ public RankFeatureQueryDescriptor<T> Logarithm(Func<RankFeatureLogarithmFunction
56
56
/// <inheritdoc cref="IRankFeatureSigmoidFunction"/>
57
57
public RankFeatureQueryDescriptor < T > Sigmoid ( Func < RankFeatureSigmoidFunctionDescriptor , IRankFeatureSigmoidFunction > selector ) =>
58
58
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
+ }
59
66
}
60
67
61
68
/// <summary>
@@ -164,6 +171,24 @@ public class RankFeatureSigmoidFunctionDescriptor
164
171
public RankFeatureSigmoidFunctionDescriptor Pivot ( float pivot ) => Assign ( pivot , ( a , v ) => a . Pivot = v ) ;
165
172
}
166
173
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
+
167
192
internal class RankFeatureQueryFormatter : IJsonFormatter < IRankFeatureQuery >
168
193
{
169
194
public void Serialize ( ref JsonWriter writer , IRankFeatureQuery value , IJsonFormatterResolver formatterResolver )
@@ -208,6 +233,9 @@ public void Serialize(ref JsonWriter writer, IRankFeatureQuery value, IJsonForma
208
233
case IRankFeatureLogarithmFunction log :
209
234
SerializeScoreFunction ( ref writer , "log" , log , formatterResolver ) ;
210
235
break ;
236
+ case IRankFeatureLinearFunction log :
237
+ SerializeScoreFunction ( ref writer , "linear" , log , formatterResolver ) ;
238
+ break ;
211
239
}
212
240
}
213
241
@@ -234,7 +262,8 @@ private static IRankFeatureFunction DeserializeScoreFunction<TScoreFunction>(ref
234
262
{ "field" , 2 } ,
235
263
{ "saturation" , 3 } ,
236
264
{ "log" , 4 } ,
237
- { "sigmoid" , 5 }
265
+ { "sigmoid" , 5 } ,
266
+ { "linear" , 6 }
238
267
} ;
239
268
240
269
public IRankFeatureQuery Deserialize ( ref JsonReader reader , IJsonFormatterResolver formatterResolver )
@@ -268,6 +297,9 @@ public IRankFeatureQuery Deserialize(ref JsonReader reader, IJsonFormatterResolv
268
297
case 5 :
269
298
query . Function = DeserializeScoreFunction < RankFeatureSigmoidFunction > ( ref reader , formatterResolver ) ;
270
299
break ;
300
+ case 6 :
301
+ query . Function = DeserializeScoreFunction < RankFeatureLinearFunction > ( ref reader , formatterResolver ) ;
302
+ break ;
271
303
}
272
304
}
273
305
else
0 commit comments