-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAbstractDictionary.php
More file actions
68 lines (51 loc) · 1.37 KB
/
AbstractDictionary.php
File metadata and controls
68 lines (51 loc) · 1.37 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
declare(strict_types = 1);
namespace Spameri\ElasticQuery\Mapping\Analyzer;
abstract class AbstractDictionary
implements \Spameri\ElasticQuery\Mapping\CustomAnalyzerInterface,
\Spameri\ElasticQuery\Collection\Item
{
protected \Spameri\ElasticQuery\Mapping\Settings\Analysis\FilterCollection|null $filter = null;
public function __construct(
protected \Spameri\ElasticQuery\Mapping\Filter\AbstractStop|null $stopFilter = null,
)
{
}
public function key(): string
{
return $this->name();
}
public function getType(): string
{
return 'custom';
}
public function tokenizer(): string
{
return 'standard';
}
public function getStopFilter(): \Spameri\ElasticQuery\Mapping\Filter\AbstractStop|null
{
return $this->stopFilter;
}
public function toArray(): array
{
$filterArray = [];
/** @var \Spameri\ElasticQuery\Mapping\FilterInterface $filter */
foreach ($this->filter() as $filter) {
if ($filter instanceof \Spameri\ElasticQuery\Mapping\Filter\AbstractHunspell) {
$filterArray[] = $filter->getName();
} elseif ($filter instanceof \Spameri\ElasticQuery\Mapping\Filter\AbstractStop) {
$filterArray[] = $filter->getName();
} else {
$filterArray[] = $filter->getType();
}
}
return [
$this->name() => [
'type' => $this->getType(),
'tokenizer' => $this->tokenizer(),
'filter' => $filterArray,
],
];
}
}