File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ public interface IFunctionScoreQuery : IQuery
4040
4141 [ JsonProperty ( PropertyName = "weight" ) ]
4242 double ? WeightAsDouble { get ; set ; }
43+
44+ [ JsonProperty ( PropertyName = "min_score" ) ]
45+ float ? MinScore { get ; set ; }
4346 }
4447
4548 public class FunctionScoreQuery : PlainQuery , IFunctionScoreQuery
@@ -67,6 +70,7 @@ public long? Weight
6770 }
6871
6972 public double ? WeightAsDouble { get ; set ; }
73+ public float ? MinScore { get ; set ; }
7074 }
7175
7276 public class FunctionScoreQueryDescriptor < T > : IFunctionScoreQuery where T : class
@@ -95,6 +99,7 @@ public class FunctionScoreQueryDescriptor<T> : IFunctionScoreQuery where T : cla
9599
96100 // TODO: Remove in 2.0 and change Weight to double
97101 double ? IFunctionScoreQuery . WeightAsDouble { get ; set ; }
102+ float ? IFunctionScoreQuery . MinScore { get ; set ; }
98103
99104 string IQuery . Name { get ; set ; }
100105
@@ -202,5 +207,11 @@ public FunctionScoreQueryDescriptor<T> Weight(long weight)
202207 Self . Weight = weight ;
203208 return this ;
204209 }
210+
211+ public FunctionScoreQueryDescriptor < T > MinScore ( float minScore )
212+ {
213+ Self . MinScore = minScore ;
214+ return this ;
215+ }
205216 }
206217}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public void FunctionScore_Deserializes()
1616 f=> f . FunctionScore ( fq=> fq
1717 . BoostMode ( FunctionBoostMode . Average )
1818 . MaxBoost ( 0.95f )
19+ . MinScore ( 1.1f )
1920 . Functions (
2021 ff => ff . Gauss ( x => x . StartedOn , d => d . Scale ( "42w" ) ) . Weight ( 1 ) ,
2122 ff => ff . Linear ( x => x . FloatValue , d => d . Scale ( "0.3" ) ) . Filter ( lff=> Filter2 ) . Weight ( 2 ) ,
@@ -36,6 +37,7 @@ public void FunctionScore_Deserializes()
3637
3738 q . BoostMode . Should ( ) . Be ( FunctionBoostMode . Average ) ;
3839 q . MaxBoost . Should ( ) . Be ( 0.95f ) ;
40+ q . MinScore . Should ( ) . Be ( 1.1f ) ;
3941 q . RandomScore . Should ( ) . NotBeNull ( ) ;
4042 q . RandomScore . Seed . Should ( ) . Be ( 1337 ) ;
4143 q . ScoreMode . Should ( ) . Be ( FunctionScoreMode . First ) ;
Original file line number Diff line number Diff line change @@ -288,5 +288,46 @@ public void TestDecayFunction()
288288 }" ;
289289 Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
290290 }
291+
292+ [ Test ]
293+ public void TestMinScore ( )
294+ {
295+ var s = new SearchDescriptor < ElasticsearchProject > ( )
296+ . Query ( q => q
297+ . FunctionScore ( fs => fs
298+ . MinScore ( 1.1f )
299+ . Functions (
300+ f => f
301+ . BoostFactor ( 2 )
302+ . Filter (
303+ filter => filter . Term ( "term1" , "termValue" )
304+ )
305+ . Weight ( 0.5 )
306+ )
307+ )
308+
309+ ) ;
310+ var json = TestElasticClient . Serialize ( s ) ;
311+ var expected = @"{
312+ query: {
313+ function_score: {
314+ functions : [
315+ {
316+ boost_factor: 2.0,
317+ filter:{
318+ term : {
319+ ""term1"":""termValue""
320+ }
321+ },
322+ weight: 0.5
323+ }
324+ ],
325+ min_score: 1.1
326+ }
327+ }
328+ }" ;
329+
330+ Assert . True ( json . JsonEquals ( expected ) , json ) ;
331+ }
291332 }
292333}
You can’t perform that action at this time.
0 commit comments