1
1
<?php
2
2
3
3
namespace Elastica \Query ;
4
+
4
5
use Elastica \Filter \AbstractFilter ;
5
6
use Elastica \Script ;
6
7
@@ -29,7 +30,7 @@ class FunctionScore extends AbstractQuery
29
30
const DECAY_EXPONENTIAL = 'exp ' ;
30
31
const DECAY_LINEAR = 'linear ' ;
31
32
32
- protected $ _functions = array ();
33
+ protected $ functions = array ();
33
34
34
35
/**
35
36
* Set the child query for this function_score query
@@ -57,7 +58,7 @@ public function setFilter(AbstractFilter $filter)
57
58
* @param AbstractFilter $filter optional filter to apply to the function
58
59
* @return \Elastica\Query\FunctionScore
59
60
*/
60
- public function addFunction ($ functionType , $ functionParams , AbstractFilter $ filter = NULL , $ weight = null )
61
+ public function addFunction ($ functionType , $ functionParams , AbstractFilter $ filter = null , $ weight = null )
61
62
{
62
63
$ function = array (
63
64
$ functionType => $ functionParams
@@ -68,7 +69,7 @@ public function addFunction($functionType, $functionParams, AbstractFilter $filt
68
69
if ($ weight !== null ) {
69
70
$ function ['weight ' ] = $ weight ;
70
71
}
71
- $ this ->_functions [] = $ function ;
72
+ $ this ->functions [] = $ function ;
72
73
return $ this ;
73
74
}
74
75
@@ -79,7 +80,7 @@ public function addFunction($functionType, $functionParams, AbstractFilter $filt
79
80
* @param float $weight the weight of the function
80
81
* @return \Elastica\Query\FunctionScore
81
82
*/
82
- public function addScriptScoreFunction (Script $ script , AbstractFilter $ filter = NULL , $ weight = null )
83
+ public function addScriptScoreFunction (Script $ script , AbstractFilter $ filter = null , $ weight = null )
83
84
{
84
85
return $ this ->addFunction ('script_score ' , $ script ->toArray (), $ filter , $ weight );
85
86
}
@@ -90,15 +91,23 @@ public function addScriptScoreFunction(Script $script, AbstractFilter $filter =
90
91
* @param string $field the document field on which to perform the decay function
91
92
* @param string $origin the origin value for this decay function
92
93
* @param string $scale a scale to define the rate of decay for this function
93
- * @param string $offset If defined, this function will only be computed for documents with a distance from the origin greater than this value
94
+ * @param string $offset If defined, this function will only be computed for documents
95
+ * with a distance from the origin greater than this value
94
96
* @param float $decay optionally defines how documents are scored at the distance given by the $scale parameter
95
97
* @param float $weight optional factor by which to multiply the score at the value provided by the $scale parameter
96
98
* @param AbstractFilter $filter a filter associated with this function
97
99
* @return \Elastica\Query\FunctionScore
98
100
*/
99
- public function addDecayFunction ($ function , $ field , $ origin , $ scale , $ offset = NULL , $ decay = NULL , $ weight = NULL ,
100
- AbstractFilter $ filter = NULL )
101
- {
101
+ public function addDecayFunction (
102
+ $ function ,
103
+ $ field ,
104
+ $ origin ,
105
+ $ scale ,
106
+ $ offset = null ,
107
+ $ decay = null ,
108
+ $ weight = null ,
109
+ AbstractFilter $ filter = null
110
+ ) {
102
111
$ functionParams = array (
103
112
$ field => array (
104
113
'origin ' => $ origin ,
@@ -182,7 +191,7 @@ public function setBoostMode($mode)
182
191
* @param int $seed Set a seed value to return results in the same random order for consistent pagination.
183
192
* @return \Elastica\Query\FunctionScore
184
193
*/
185
- public function setRandomScore ($ seed = NULL )
194
+ public function setRandomScore ($ seed = null )
186
195
{
187
196
$ seedParam = new \stdClass ();
188
197
if (!is_null ($ seed )) {
@@ -206,8 +215,8 @@ public function setScoreMode($mode)
206
215
*/
207
216
public function toArray ()
208
217
{
209
- if (sizeof ($ this ->_functions )) {
210
- $ this ->setParam ('functions ' , $ this ->_functions );
218
+ if (sizeof ($ this ->functions )) {
219
+ $ this ->setParam ('functions ' , $ this ->functions );
211
220
}
212
221
return parent ::toArray ();
213
222
}
0 commit comments