@@ -54,6 +54,13 @@ public RankFeatureQueryDescriptor<T> Logarithm(Func<RankFeatureLogarithmFunction
54
54
/// <inheritdoc cref="IRankFeatureSigmoidFunction"/>
55
55
public RankFeatureQueryDescriptor < T > Sigmoid ( Func < RankFeatureSigmoidFunctionDescriptor , IRankFeatureSigmoidFunction > selector ) =>
56
56
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
+ }
57
64
}
58
65
59
66
/// <summary>
@@ -162,6 +169,24 @@ public class RankFeatureSigmoidFunctionDescriptor
162
169
public RankFeatureSigmoidFunctionDescriptor Pivot ( float pivot ) => Assign ( pivot , ( a , v ) => a . Pivot = v ) ;
163
170
}
164
171
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
+
165
190
internal class RankFeatureQueryFormatter : IJsonFormatter < IRankFeatureQuery >
166
191
{
167
192
public void Serialize ( ref JsonWriter writer , IRankFeatureQuery value , IJsonFormatterResolver formatterResolver )
@@ -206,6 +231,9 @@ public void Serialize(ref JsonWriter writer, IRankFeatureQuery value, IJsonForma
206
231
case IRankFeatureLogarithmFunction log :
207
232
SerializeScoreFunction ( ref writer , "log" , log , formatterResolver ) ;
208
233
break ;
234
+ case IRankFeatureLinearFunction log :
235
+ SerializeScoreFunction ( ref writer , "linear" , log , formatterResolver ) ;
236
+ break ;
209
237
}
210
238
}
211
239
@@ -232,7 +260,8 @@ private static IRankFeatureFunction DeserializeScoreFunction<TScoreFunction>(ref
232
260
{ "field" , 2 } ,
233
261
{ "saturation" , 3 } ,
234
262
{ "log" , 4 } ,
235
- { "sigmoid" , 5 }
263
+ { "sigmoid" , 5 } ,
264
+ { "linear" , 6 }
236
265
} ;
237
266
238
267
public IRankFeatureQuery Deserialize ( ref JsonReader reader , IJsonFormatterResolver formatterResolver )
@@ -266,6 +295,9 @@ public IRankFeatureQuery Deserialize(ref JsonReader reader, IJsonFormatterResolv
266
295
case 5 :
267
296
query . Function = DeserializeScoreFunction < RankFeatureSigmoidFunction > ( ref reader , formatterResolver ) ;
268
297
break ;
298
+ case 6 :
299
+ query . Function = DeserializeScoreFunction < RankFeatureLinearFunction > ( ref reader , formatterResolver ) ;
300
+ break ;
269
301
}
270
302
}
271
303
else
0 commit comments