Skip to content

Commit 87c2b5a

Browse files
committed
CommonGrams filter - now configure common_words
1 parent 4c1451f commit 87c2b5a

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/Mapping/Filter/CommonGrams.php

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

11+
/**
12+
* @var array<string>
13+
*/
14+
private $words;
15+
16+
17+
public function __construct(array $words)
18+
{
19+
$this->words = $words;
20+
}
21+
22+
1123
public function getType(): string
1224
{
1325
return 'common_grams';
1426
}
1527

28+
29+
public function key(): string
30+
{
31+
return 'customCommonGrams';
32+
}
33+
34+
35+
public function toArray(): array
36+
{
37+
return [
38+
$this->key() => [
39+
'type' => $this->getType(),
40+
'common_words' => $this->words,
41+
],
42+
];
43+
}
1644
}

0 commit comments

Comments
 (0)