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 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function getType() |
||
53 | |||
54 | /** |
||
55 | * Modifier to apply filter to the function score function. |
||
56 | * |
||
57 | * @param array $function |
||
58 | * @param BuilderInterface $query |
||
59 | */ |
||
60 | private function applyFilter(array &$function, BuilderInterface $query = null) |
||
66 | |||
67 | /** |
||
68 | * Creates field_value_factor function. |
||
69 | * |
||
70 | * @param string $field |
||
71 | * @param float $factor |
||
72 | * @param string $modifier |
||
73 | * @param BuilderInterface $query |
||
74 | * |
||
75 | * @return $this |
||
76 | */ |
||
77 | public function addFieldValueFactorFunction($field, $factor, $modifier = 'none', BuilderInterface $query = null) |
||
93 | |||
94 | /** |
||
95 | * Add decay function to function score. Weight and query are optional. |
||
96 | * |
||
97 | * @param string $type |
||
98 | * @param string $field |
||
99 | * @param array $function |
||
100 | * @param array $options |
||
101 | * @param BuilderInterface $query |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function addDecayFunction( |
||
125 | |||
126 | /** |
||
127 | * Adds function to function score without decay function. Influence search score only for specific query. |
||
128 | * |
||
129 | * @param float $weight |
||
130 | * @param BuilderInterface $query |
||
131 | * |
||
132 | * @return $this |
||
133 | */ |
||
134 | public function addWeightFunction($weight, BuilderInterface $query = null) |
||
146 | |||
147 | /** |
||
148 | * Adds random score function. Seed is optional. |
||
149 | * |
||
150 | * @param mixed $seed |
||
151 | * @param BuilderInterface $query |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | public function addRandomFunction($seed = null, BuilderInterface $query = null) |
||
167 | |||
168 | /** |
||
169 | * Adds script score function. |
||
170 | * |
||
171 | * @param string $script |
||
172 | * @param array $params |
||
173 | * @param array $options |
||
174 | * @param BuilderInterface $query |
||
175 | * |
||
176 | * @return $this |
||
177 | */ |
||
178 | public function addScriptScoreFunction( |
||
209 | |||
210 | /** |
||
211 | * Adds custom simple function. You can add to the array whatever you want. |
||
212 | * |
||
213 | * @param array $function |
||
214 | * |
||
215 | * @return $this |
||
216 | */ |
||
217 | public function addSimpleFunction(array $function) |
||
223 | |||
224 | /** |
||
225 | * {@inheritdoc} |
||
226 | */ |
||
227 | public function toArray() |
||
238 | } |
||
239 |