Skip to content

Commit 89d9e5c

Browse files
committed
Synonym Filter
1 parent 112375c commit 89d9e5c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/Mapping/Filter/Synonym.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,52 @@
88
class Synonym implements \Spameri\ElasticQuery\Mapping\FilterInterface
99
{
1010

11+
/**
12+
* @var array<string>
13+
*/
14+
private $synonyms;
15+
16+
17+
public function __construct(
18+
array $synonyms = []
19+
)
20+
{
21+
$this->synonyms = $synonyms;
22+
}
23+
24+
1125
public function getType(): string
1226
{
1327
return 'synonym';
1428
}
1529

30+
31+
public function getSynonyms() : array
32+
{
33+
return $this->synonyms;
34+
}
35+
36+
37+
public function getName() : string
38+
{
39+
return 'customSynonyms';
40+
}
41+
42+
43+
public function key() : string
44+
{
45+
return $this->getName();
46+
}
47+
48+
49+
public function toArray() : array
50+
{
51+
return [
52+
$this->getName() => [
53+
'type' => $this->getType(),
54+
'synonyms' => $this->synonyms,
55+
],
56+
];
57+
}
58+
1659
}

0 commit comments

Comments
 (0)