@@ -37,7 +37,19 @@ public FunctionScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : ba
3737 MinScore = 1.0 ,
3838 Functions = new List < IScoreFunction >
3939 {
40- new ExponentialDecayFunction { Origin = 1.0 , Decay = 0.5 , Field = Field < Project > ( p => p . NumberOfCommits ) , Scale = 0.1 , Weight = 2.1 } ,
40+ new ExponentialDecayFunction
41+ {
42+ Origin = 1.0 ,
43+ Decay = 0.5 ,
44+ Field = Field < Project > ( p => p . NumberOfCommits ) ,
45+ Scale = 0.1 ,
46+ Weight = 2.1 ,
47+ Filter = new NumericRangeQuery
48+ {
49+ Field = Field < Project > ( f => f . NumberOfContributors ) ,
50+ GreaterThan = 10
51+ }
52+ } ,
4153 new GaussDateDecayFunction
4254 { Origin = DateMath . Now , Field = Field < Project > ( p => p . LastActivity ) , Decay = 0.5 , Scale = TimeSpan . FromDays ( 1 ) } ,
4355 new LinearGeoDecayFunction
@@ -52,7 +64,7 @@ public FunctionScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : ba
5264 new RandomScoreFunction { Seed = 1337 , Field = "_seq_no" } ,
5365 new RandomScoreFunction { Seed = "randomstring" , Field = "_seq_no" } ,
5466 new WeightFunction { Weight = 1.0 } ,
55- new ScriptScoreFunction { Script = new InlineScript ( "Math.log(2 + doc['numberOfCommits'].value)" ) }
67+ new ScriptScoreFunction { Script = new InlineScript ( "Math.log(2 + doc['numberOfCommits'].value)" ) , Weight = 2.0 }
5668 }
5769 } ;
5870
@@ -76,7 +88,17 @@ public FunctionScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : ba
7688 decay = 0.5
7789 }
7890 } ,
79- weight = 2.1
91+ weight = 2.1 ,
92+ filter = new
93+ {
94+ range = new
95+ {
96+ numberOfContributors = new
97+ {
98+ gt = 10.0
99+ }
100+ }
101+ }
80102 } ,
81103 new
82104 {
@@ -127,7 +149,8 @@ public FunctionScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : ba
127149 {
128150 source = "Math.log(2 + doc['numberOfCommits'].value)"
129151 }
130- }
152+ } ,
153+ weight = 2.0
131154 }
132155 } ,
133156 max_boost = 20.0 ,
@@ -150,15 +173,36 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
150173 . MaxBoost ( 20.0 )
151174 . MinScore ( 1.0 )
152175 . Functions ( f => f
153- . Exponential ( b => b . Field ( p => p . NumberOfCommits ) . Decay ( 0.5 ) . Origin ( 1.0 ) . Scale ( 0.1 ) . Weight ( 2.1 ) )
176+ . Exponential ( b => b
177+ . Field ( p => p . NumberOfCommits )
178+ . Decay ( 0.5 )
179+ . Origin ( 1.0 )
180+ . Scale ( 0.1 )
181+ . Weight ( 2.1 )
182+ . Filter ( fi => fi
183+ . Range ( r => r
184+ . Field ( p => p . NumberOfContributors )
185+ . GreaterThan ( 10 )
186+ )
187+ )
188+ )
154189 . GaussDate ( b => b . Field ( p => p . LastActivity ) . Origin ( DateMath . Now ) . Decay ( 0.5 ) . Scale ( "1d" ) )
155- . LinearGeoLocation ( b =>
156- b . Field ( p => p . LocationPoint ) . Origin ( new GeoLocation ( 70 , - 70 ) ) . Scale ( Distance . Miles ( 1 ) ) . MultiValueMode ( MultiValueMode . Average ) )
190+ . LinearGeoLocation ( b => b
191+ . Field ( p => p . LocationPoint )
192+ . Origin ( new GeoLocation ( 70 , - 70 ) )
193+ . Scale ( Distance . Miles ( 1 ) )
194+ . MultiValueMode ( MultiValueMode . Average )
195+ )
157196 . FieldValueFactor ( b => b . Field ( p => p . NumberOfContributors ) . Factor ( 1.1 ) . Missing ( 0.1 ) . Modifier ( FieldValueFactorModifier . Square ) )
158197 . RandomScore ( r => r . Seed ( 1337 ) . Field ( "_seq_no" ) )
159198 . RandomScore ( r => r . Seed ( "randomstring" ) . Field ( "_seq_no" ) )
160199 . Weight ( 1.0 )
161- . ScriptScore ( s => s . Script ( ss => ss . Source ( "Math.log(2 + doc['numberOfCommits'].value)" ) ) )
200+ . ScriptScore ( s => s
201+ . Script ( ss => ss
202+ . Source ( "Math.log(2 + doc['numberOfCommits'].value)" )
203+ )
204+ . Weight ( 2 )
205+ )
162206 )
163207 ) ;
164208 }
0 commit comments