-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSettings.php
More file actions
49 lines (38 loc) · 1.05 KB
/
Settings.php
File metadata and controls
49 lines (38 loc) · 1.05 KB
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
43
44
45
46
47
48
49
<?php
declare(strict_types = 1);
namespace Spameri\ElasticQuery\Document\Body;
class Settings implements \Spameri\ElasticQuery\Document\BodyInterface
{
public function __construct(
private \Spameri\ElasticQuery\Mapping\Settings\Analysis\AnalyzerCollection $analyzer,
private \Spameri\ElasticQuery\Mapping\Settings\Analysis\FilterCollection $filter,
)
{
}
public function toArray(): array
{
$analyzers = [];
/** @var \Spameri\ElasticQuery\Mapping\AnalyzerInterface&\Spameri\ElasticQuery\Collection\Item $analyzer */
foreach ($this->analyzer as $analyzer) {
$analyzers[$analyzer->key()] = $analyzer->toArray()[$analyzer->key()];
}
$filters = [];
/** @var \Spameri\ElasticQuery\Mapping\FilterInterface $filter */
foreach ($this->filter as $filter) {
if ($filter->toArray() === []) {
continue;
}
$filters[$filter->key()] = $filter->toArray()[$filter->key()];
}
return [
'settings' => [
'analysis' => [
'analyzer' => $analyzers,
'tokenizer' => [
],
'filter' => $filters,
],
],
];
}
}