@@ -37,7 +37,19 @@ public FunctionScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : ba
37
37
MinScore = 1.0 ,
38
38
Functions = new List < IScoreFunction >
39
39
{
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
+ } ,
41
53
new GaussDateDecayFunction
42
54
{ Origin = DateMath . Now , Field = Field < Project > ( p => p . LastActivity ) , Decay = 0.5 , Scale = TimeSpan . FromDays ( 1 ) } ,
43
55
new LinearGeoDecayFunction
@@ -52,7 +64,7 @@ public FunctionScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : ba
52
64
new RandomScoreFunction { Seed = 1337 , Field = "_seq_no" } ,
53
65
new RandomScoreFunction { Seed = "randomstring" , Field = "_seq_no" } ,
54
66
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 }
56
68
}
57
69
} ;
58
70
@@ -76,7 +88,17 @@ public FunctionScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : ba
76
88
decay = 0.5
77
89
}
78
90
} ,
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
+ }
80
102
} ,
81
103
new
82
104
{
@@ -127,7 +149,8 @@ public FunctionScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : ba
127
149
{
128
150
source = "Math.log(2 + doc['numberOfCommits'].value)"
129
151
}
130
- }
152
+ } ,
153
+ weight = 2.0
131
154
}
132
155
} ,
133
156
max_boost = 20.0 ,
@@ -150,15 +173,36 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
150
173
. MaxBoost ( 20.0 )
151
174
. MinScore ( 1.0 )
152
175
. 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
+ )
154
189
. 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
+ )
157
196
. FieldValueFactor ( b => b . Field ( p => p . NumberOfContributors ) . Factor ( 1.1 ) . Missing ( 0.1 ) . Modifier ( FieldValueFactorModifier . Square ) )
158
197
. RandomScore ( r => r . Seed ( 1337 ) . Field ( "_seq_no" ) )
159
198
. RandomScore ( r => r . Seed ( "randomstring" ) . Field ( "_seq_no" ) )
160
199
. 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
+ )
162
206
)
163
207
) ;
164
208
}
0 commit comments