1 | <?php |
||
22 | class FunctionScoreQuery implements BuilderInterface |
||
23 | { |
||
24 | use ParametersTrait; |
||
25 | |||
26 | /** |
||
27 | * @var BuilderInterface |
||
28 | */ |
||
29 | private $query; |
||
30 | |||
31 | /** |
||
32 | * @var array[] |
||
33 | */ |
||
34 | private $functions; |
||
35 | |||
36 | /** |
||
37 | * @param BuilderInterface $query |
||
38 | * @param array $parameters |
||
39 | */ |
||
40 | public function __construct(BuilderInterface $query, array $parameters = []) |
||
45 | |||
46 | /** |
||
47 | * Creates field_value_factor function. |
||
48 | * |
||
49 | * @param string $field |
||
50 | * @param float $factor |
||
51 | * @param string $modifier |
||
52 | * @param BuilderInterface $query |
||
53 | * |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function addFieldValueFactorFunction($field, $factor, $modifier = 'none', BuilderInterface $query = null) |
||
72 | |||
73 | /** |
||
74 | * Modifier to apply filter to the function score function. |
||
75 | * |
||
76 | * @param array $function |
||
77 | * @param BuilderInterface $query |
||
78 | */ |
||
79 | private function applyFilter(array &$function, BuilderInterface $query = null) |
||
85 | |||
86 | /** |
||
87 | * Add decay function to function score. Weight and query are optional. |
||
88 | * |
||
89 | * @param string $type |
||
90 | * @param string $field |
||
91 | * @param array $function |
||
92 | * @param array $options |
||
93 | * @param BuilderInterface $query |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function addDecayFunction( |
||
117 | |||
118 | /** |
||
119 | * Adds function to function score without decay function. Influence search score only for specific query. |
||
120 | * |
||
121 | * @param float $weight |
||
122 | * @param BuilderInterface $query |
||
123 | * |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function addWeightFunction($weight, BuilderInterface $query = null) |
||
138 | |||
139 | /** |
||
140 | * Adds random score function. Seed is optional. |
||
141 | * |
||
142 | * @param mixed $seed |
||
143 | * @param BuilderInterface $query |
||
144 | * |
||
145 | * @return $this |
||
146 | */ |
||
147 | public function addRandomFunction($seed = null, BuilderInterface $query = null) |
||
159 | |||
160 | /** |
||
161 | * Adds script score function. |
||
162 | * |
||
163 | * @param string $inline |
||
164 | * @param array $params |
||
165 | * @param array $options |
||
166 | * @param BuilderInterface $query |
||
167 | * |
||
168 | * @return $this |
||
169 | */ |
||
170 | public function addScriptScoreFunction( |
||
197 | |||
198 | /** |
||
199 | * Adds custom simple function. You can add to the array whatever you want. |
||
200 | * |
||
201 | * @param array $function |
||
202 | * |
||
203 | * @return $this |
||
204 | */ |
||
205 | public function addSimpleFunction(array $function) |
||
211 | |||
212 | /** |
||
213 | * {@inheritdoc} |
||
214 | */ |
||
215 | public function toArray() |
||
226 | |||
227 | /** |
||
228 | * {@inheritdoc} |
||
229 | */ |
||
230 | public function getType() |
||
234 | } |
||
235 |