-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBoosting.php
More file actions
42 lines (33 loc) · 866 Bytes
/
Boosting.php
File metadata and controls
42 lines (33 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types = 1);
namespace Spameri\ElasticQuery\Query;
/**
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html
*/
class Boosting implements \Spameri\ElasticQuery\Query\LeafQueryInterface
{
public function __construct(
private \Spameri\ElasticQuery\Query\LeafQueryInterface $positive,
private \Spameri\ElasticQuery\Query\LeafQueryInterface $negative,
private float $negativeBoost,
)
{
}
public function key(): string
{
return 'boosting_' . $this->positive->key() . '_' . $this->negative->key();
}
/**
* @return array<string, array<string, mixed>>
*/
public function toArray(): array
{
return [
'boosting' => [
'positive' => $this->positive->toArray(),
'negative' => $this->negative->toArray(),
'negative_boost' => $this->negativeBoost,
],
];
}
}