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 | * Returns the query instance. |
||
48 | * |
||
49 | * @return BuilderInterface object |
||
50 | */ |
||
51 | public function getQuery() |
||
55 | |||
56 | /** |
||
57 | * Creates field_value_factor function. |
||
58 | * |
||
59 | * @param string $field |
||
60 | * @param float $factor |
||
61 | * @param string $modifier |
||
62 | * @param BuilderInterface $query |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function addFieldValueFactorFunction($field, $factor, $modifier = 'none', BuilderInterface $query = null) |
||
82 | |||
83 | /** |
||
84 | * Modifier to apply filter to the function score function. |
||
85 | * |
||
86 | * @param array $function |
||
87 | * @param BuilderInterface $query |
||
88 | */ |
||
89 | private function applyFilter(array &$function, BuilderInterface $query = null) |
||
95 | |||
96 | /** |
||
97 | * Add decay function to function score. Weight and query are optional. |
||
98 | * |
||
99 | * @param string $type |
||
100 | * @param string $field |
||
101 | * @param array $function |
||
102 | * @param array $options |
||
103 | * @param BuilderInterface $query |
||
104 | * @param int $weight |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function addDecayFunction( |
||
132 | |||
133 | /** |
||
134 | * Adds function to function score without decay function. Influence search score only for specific query. |
||
135 | * |
||
136 | * @param float $weight |
||
137 | * @param BuilderInterface $query |
||
138 | * |
||
139 | * @return $this |
||
140 | */ |
||
141 | public function addWeightFunction($weight, BuilderInterface $query = null) |
||
153 | |||
154 | /** |
||
155 | * Adds random score function. Seed is optional. |
||
156 | * |
||
157 | * @param mixed $seed |
||
158 | * @param BuilderInterface $query |
||
159 | * |
||
160 | * @return $this |
||
161 | */ |
||
162 | public function addRandomFunction($seed = null, BuilderInterface $query = null) |
||
174 | |||
175 | /** |
||
176 | * Adds script score function. |
||
177 | * |
||
178 | * @param string $inline |
||
179 | * @param array $params |
||
180 | * @param array $options |
||
181 | * @param BuilderInterface $query |
||
182 | * |
||
183 | * @return $this |
||
184 | */ |
||
185 | public function addScriptScoreFunction( |
||
212 | |||
213 | /** |
||
214 | * Adds custom simple function. You can add to the array whatever you want. |
||
215 | * |
||
216 | * @param array $function |
||
217 | * |
||
218 | * @return $this |
||
219 | */ |
||
220 | public function addSimpleFunction(array $function) |
||
226 | |||
227 | /** |
||
228 | * {@inheritdoc} |
||
229 | */ |
||
230 | public function toArray() |
||
241 | |||
242 | /** |
||
243 | * {@inheritdoc} |
||
244 | */ |
||
245 | public function getType() |
||
249 | } |
||
250 |