File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Tests/Nest.Tests.Unit/Search/Query/Singles Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ public class FunctionScoreQueryDescriptor<T> : IQuery where T : class
2525 [ JsonConverter ( typeof ( StringEnumConverter ) ) ]
2626 FunctionScoreMode ? _ScoreMode { get ; set ; }
2727
28+ [ JsonProperty ( PropertyName = "boost_mode" ) ]
29+ [ JsonConverter ( typeof ( StringEnumConverter ) ) ]
30+ FunctionBoostMode ? _BoostMode { get ; set ; }
31+
2832 [ JsonProperty ( PropertyName = "random_score" ) ]
2933 RandomScoreFunction _RandomScore { get ; set ; }
3034
@@ -69,6 +73,12 @@ public FunctionScoreQueryDescriptor<T> ScoreMode(FunctionScoreMode mode)
6973 return this ;
7074 }
7175
76+ public FunctionScoreQueryDescriptor < T > BoostMode ( FunctionBoostMode mode )
77+ {
78+ this . _BoostMode = mode ;
79+ return this ;
80+ }
81+
7282 public FunctionScoreQueryDescriptor < T > RandomScore ( int ? seed = null )
7383 {
7484 this . _RandomScore = new RandomScoreFunction ( ) ;
@@ -101,6 +111,16 @@ public enum FunctionScoreMode
101111 min
102112 }
103113
114+ public enum FunctionBoostMode
115+ {
116+ multiply ,
117+ replace ,
118+ sum ,
119+ avg ,
120+ max ,
121+ min
122+ }
123+
104124 public class FunctionScoreFunctionsDescriptor < T > : IEnumerable < FunctionScoreFunction < T > > where T : class
105125 {
106126 internal List < FunctionScoreFunction < T > > _Functions { get ; set ; }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ public void FunctionScoreQuery()
2121 f => f . BoostFactor ( 2 )
2222 )
2323 . ScoreMode ( FunctionScoreMode . sum )
24+ . BoostMode ( FunctionBoostMode . replace )
2425 )
2526 ) . Fields ( x => x . Content ) ;
2627
@@ -36,7 +37,8 @@ public void FunctionScoreQuery()
3637 {boost_factor: 2.0 }
3738 ],
3839 query : { match_all : {} },
39- score_mode: 'sum'
40+ score_mode: 'sum',
41+ boost_mode: 'replace',
4042 }
4143 },
4244 fields: [""content""]
You can’t perform that action at this time.
0 commit comments