1 | <?php |
||
20 | class FunctionScoreQuery implements BuilderInterface |
||
21 | { |
||
22 | use ParametersTrait; |
||
23 | |||
24 | /** |
||
25 | * Query of filter. |
||
26 | * |
||
27 | * In Function score could be used query or filter. Use setDslType() to change type. |
||
28 | * |
||
29 | * @var BuilderInterface |
||
30 | */ |
||
31 | private $query; |
||
32 | |||
33 | /** |
||
34 | * @var array[] |
||
35 | */ |
||
36 | private $functions; |
||
37 | |||
38 | /** |
||
39 | * @param BuilderInterface $query |
||
40 | * @param array $parameters |
||
41 | */ |
||
42 | public function __construct(BuilderInterface $query, array $parameters = []) |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | public function getType() |
||
55 | |||
56 | /** |
||
57 | * Modifier to apply query to the function score function. |
||
58 | * |
||
59 | * @param array $function |
||
60 | * @param BuilderInterface $query |
||
61 | */ |
||
62 | private function applyQuery(array &$function, BuilderInterface $query = null) |
||
70 | |||
71 | /** |
||
72 | * Creates field_value_factor function. |
||
73 | * |
||
74 | * @param string $field |
||
75 | * @param float $factor |
||
76 | * @param string $modifier |
||
77 | * @param BuilderInterface $query |
||
78 | * |
||
79 | * @return $this |
||
80 | */ |
||
81 | public function addFieldValueFactorFunction($field, $factor, $modifier = 'none', BuilderInterface $query = null) |
||
97 | |||
98 | /** |
||
99 | * Add decay function to function score. Weight and query are optional. |
||
100 | * |
||
101 | * @param string $type |
||
102 | * @param string $field |
||
103 | * @param array $function |
||
104 | * @param array $options |
||
105 | * @param BuilderInterface $query |
||
106 | * |
||
107 | * @return $this |
||
108 | */ |
||
109 | public function addDecayFunction( |
||
129 | |||
130 | /** |
||
131 | * Adds function to function score without decay function. Influence search score only for specific query. |
||
132 | * |
||
133 | * @param float $weight |
||
134 | * @param BuilderInterface $query |
||
135 | * |
||
136 | * @return $this |
||
137 | */ |
||
138 | public function addWeightFunction($weight, BuilderInterface $query = null) |
||
150 | |||
151 | /** |
||
152 | * Adds random score function. Seed is optional. |
||
153 | * |
||
154 | * @param mixed $seed |
||
155 | * @param BuilderInterface $query |
||
156 | * |
||
157 | * @return $this |
||
158 | */ |
||
159 | public function addRandomFunction($seed = null, BuilderInterface $query = null) |
||
171 | |||
172 | /** |
||
173 | * Adds script score function. |
||
174 | * |
||
175 | * @param string $script |
||
176 | * @param array $params |
||
177 | * @param array $options |
||
178 | * @param BuilderInterface $query |
||
179 | * |
||
180 | * @return $this |
||
181 | */ |
||
182 | public function addScriptScoreFunction( |
||
204 | |||
205 | /** |
||
206 | * Adds custom simple function. You can add to the array whatever you want. |
||
207 | * |
||
208 | * @param array $function |
||
209 | * |
||
210 | * @return $this |
||
211 | */ |
||
212 | public function addSimpleFunction(array $function) |
||
218 | |||
219 | /** |
||
220 | * {@inheritdoc} |
||
221 | */ |
||
222 | public function toArray() |
||
235 | } |
||
236 |