Skip to content

Commit 83e26eb

Browse files
committed
EdgeNgram configurable grams
1 parent 87c2b5a commit 83e26eb

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

src/Mapping/Filter/EdgeNgram.php

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

11+
/**
12+
* @var int
13+
*/
14+
private $minGram;
15+
16+
/**
17+
* @var int
18+
*/
19+
private $maxGram;
20+
21+
22+
public function __construct(
23+
int $minGram = 2,
24+
int $maxGram = 6
25+
)
26+
{
27+
$this->minGram = $minGram;
28+
$this->maxGram = $maxGram;
29+
}
30+
31+
1132
public function getType(): string
1233
{
1334
return 'edge_ngram';
1435
}
1536

37+
38+
public function key(): string
39+
{
40+
return 'customEdgeNgram';
41+
}
42+
43+
44+
public function toArray(): array
45+
{
46+
return [
47+
$this->key() => [
48+
'type' => 'edge_ngram',
49+
'min_gram' => $this->minGram,
50+
'max_gram' => $this->maxGram,
51+
],
52+
];
53+
}
54+
1655
}

0 commit comments

Comments
 (0)