Skip to content

Commit 95c294e

Browse files
committed
Dictionary can have custom defined stopWords filter
1 parent 1f13069 commit 95c294e

23 files changed

+412
-138
lines changed

src/Mapping/Analyzer/Custom/ArabicDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Arabic()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Arabic()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\Arabic()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Arabic()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Arabic()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

src/Mapping/Analyzer/Custom/BulgarianDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Bulgarian()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Bulgarian()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\Bulgarian()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Bulgarian()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Bulgarian()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

src/Mapping/Analyzer/Custom/CatalanDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Catalan()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Catalan()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\Catalan()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Catalan()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Catalan()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

src/Mapping/Analyzer/Custom/CzechDictionary.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,28 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Czech()
23-
);
21+
if ($this->stopFilter) {
22+
$this->filter->add($this->stopFilter);
23+
24+
} else {
25+
$this->filter->add(
26+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Czech()
27+
);
28+
}
2429
$this->filter->add(
2530
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\Czech()
2631
);
2732
$this->filter->add(
2833
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2934
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Czech()
32-
);
35+
if ($this->stopFilter) {
36+
$this->filter->add($this->stopFilter);
37+
38+
} else {
39+
$this->filter->add(
40+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Czech()
41+
);
42+
}
3343
$this->filter->add(
3444
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3545
);

src/Mapping/Analyzer/Custom/DanishDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Danish()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Danish()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\Danish()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Danish()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Danish()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

src/Mapping/Analyzer/Custom/DutchDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Dutch()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Dutch()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\Dutch()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Dutch()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Dutch()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

src/Mapping/Analyzer/Custom/EnglishDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\English()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\English()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\English()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\English()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\English()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

src/Mapping/Analyzer/Custom/FrenchDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\French()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\French()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\French()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\French()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\French()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

src/Mapping/Analyzer/Custom/GermanDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\German()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\German()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\German()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\German()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\German()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

src/Mapping/Analyzer/Custom/GreekDictionary.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ public function filter(): \Spameri\ElasticQuery\Mapping\Settings\Analysis\Filter
1818
$this->filter->add(
1919
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2020
);
21-
$this->filter->add(
22-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Greek()
23-
);
21+
22+
if ($this->stopFilter) {
23+
$this->filter->add($this->stopFilter);
24+
25+
} else {
26+
$this->filter->add(
27+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Greek()
28+
);
29+
}
2430
$this->filter->add(
2531
new \Spameri\ElasticQuery\Mapping\Filter\Hunspell\Greek()
2632
);
2733
$this->filter->add(
2834
new \Spameri\ElasticQuery\Mapping\Filter\Lowercase()
2935
);
30-
$this->filter->add(
31-
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Greek()
32-
);
36+
37+
if ($this->stopFilter) {
38+
$this->filter->add($this->stopFilter);
39+
40+
} else {
41+
$this->filter->add(
42+
new \Spameri\ElasticQuery\Mapping\Filter\Stop\Greek()
43+
);
44+
}
3345
$this->filter->add(
3446
new \Spameri\ElasticQuery\Mapping\Filter\Unique()
3547
);

0 commit comments

Comments
 (0)