Skip to content

Commit b4560aa

Browse files
committed
Merge branch 'release/3.4.0'
2 parents f28ca5d + 1a9d514 commit b4560aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1845
-497
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# v3.4.0
2+
## 03/06/2023
3+
4+
1. [](#improved)
5+
* Updated TNTSearch library to `2.9.0`
6+
* Enable Fuzy search [#123](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/123)
7+
* Add configuration for Levenshtein distance for fuzzy search [#124](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/124)
8+
* Added French translation [#100](https://github.com/trilbymedia/grav-plugin-tntsearch/issues/100)
9+
* Added missing stemmers [#115](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/115) [#116](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/116)
10+
111
# v3.3.1
212
## 02/25/2021
313

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ built_in_search_page: true
6868
enable_admin_page_events: true
6969
search_type: auto
7070
fuzzy: false
71+
distance: 2
7172
phrases: true
72-
stemmer: default
73+
stemmer: 'no'
7374
display_route: true
7475
display_hits: true
7576
display_time: true
@@ -103,14 +104,16 @@ The configuration options are as follows:
103104
* `boolean` - supports `or` or `minus`. e.g. `foo -bar`
104105
* `auto` - automatically detects whether to use `basic` or `boolean`
105106
* `fuzzy` - matches if the words are 'close' but not necessarily exact matches
107+
* `distance` - Levenshtein distance of fuzzy search. It represents the amount of characters which need to be changed, removed, or added in a word in order it to match the search keyword. Increasing the distance produces more search results but decreases the accuracy of the search.
106108
* `phrases` - automatically handle phrases support
107109
* `stemmer` - can be one of these types:
108-
* `default` - Porter stemmer for English language
109110
* `no` - no stemmer
110111
* `arabic` - Arabic language
112+
* `croatian` - Croatian language
111113
* `german` - German language
112114
* `italian` - Italian language
113115
* `porter` - Porter stemmer for English language
116+
* `portuguese` - Portuguese language
114117
* `russian` - Russian language
115118
* `ukrainian` - Ukrainian language
116119
* `display_route` - display the route in the search results

blueprints.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: TNT Search
22
type: plugin
33
slug: tntsearch
4-
version: 3.3.1
4+
version: 3.4.0
55
testing: false
66
description: Powerful indexed-based full text search engine powered by TNTSearch
77
icon: binoculars
@@ -150,13 +150,20 @@ form:
150150
type: toggle
151151
label: Fuzzy Search
152152
highlight: 1
153-
default: 1
153+
default: 0
154154
options:
155155
1: Enabled
156156
0: Disabled
157157
validate:
158158
type: bool
159159

160+
distance:
161+
type: number
162+
size: x-small
163+
label: Levenshtein distance of fuzzy search
164+
help: It represents the amount of characters which need to be changed, removed, or added in a word in order it to match the search keyword. Increasing the distance produces more search results but decreases the accuracy of the search.
165+
default: 2
166+
160167
phrases:
161168
type: toggle
162169
label: Match quoted phrases
@@ -174,13 +181,15 @@ form:
174181
classes: fancy
175182
label: Stemmer
176183
help: An automated process which produces a base string in an attempt to represent related words. If your content is not in the language listed, for best search results it is recommended to disable the stemmer.
184+
default: no
177185
options:
178-
default: Default (English)
179186
no: Disabled
180187
arabic: Arabic
188+
croatian: Croatian
181189
porter: English
182190
german: German
183191
italian: Italian
192+
portuguese: Portuguese
184193
russian: Russian
185194
ukrainian: Ukrainian
186195

classes/GravTNTSearch.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public function __construct($options = [])
4242
$locator = Grav::instance()['locator'];
4343

4444
$search_type = $config->get('plugins.tntsearch.search_type', 'auto');
45-
$stemmer = $config->get('plugins.tntsearch.stemmer', 'default');
45+
$fuzzy = $config->get('plugins.tntsearch.fuzzy', false);
46+
$distance = $config->get('plugins.tntsearch.distance', 2);
47+
$stemmer = $config->get('plugins.tntsearch.stemmer', 'no');
4648
$limit = $config->get('plugins.tntsearch.limit', 20);
4749
$snippet = $config->get('plugins.tntsearch.snippet', 300);
4850
$data_path = $locator->findResource('user://data', true) . '/tntsearch';
@@ -64,6 +66,8 @@ public function __construct($options = [])
6466
$defaults = [
6567
'json' => false,
6668
'search_type' => $search_type,
69+
'fuzzy' => $fuzzy,
70+
'distance' => $distance,
6771
'stemmer' => $stemmer,
6872
'limit' => $limit,
6973
'as_you_type' => true,
@@ -97,6 +101,7 @@ public function search($query)
97101

98102
if (isset($this->options['fuzzy']) && $this->options['fuzzy']) {
99103
$this->tnt->fuzziness = true;
104+
$this->tnt->fuzzy_distance = $this->options['distance'];
100105
}
101106

102107
$limit = (int)$this->options['limit'];
@@ -225,8 +230,10 @@ public function createIndex()
225230
$this->tnt->setDatabaseHandle(new GravConnector);
226231
$indexer = $this->tnt->createIndex($this->index);
227232

228-
// Set the stemmer language if set
229-
if ($this->options['stemmer'] !== 'default') {
233+
// Disable stemmer for users with older configuration.
234+
if ($this->options['stemmer'] == 'default') {
235+
$indexer->setLanguage('no');
236+
} else {
230237
$indexer->setLanguage($this->options['stemmer']);
231238
}
232239

composer.lock

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

languages.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ ru:
1313
FOUND_RESULTS: "Результатов: %s"
1414
FOUND_IN: "(<span>%s</span>)"
1515
POWERED_BY: "Работает на %s"
16+
fr:
17+
PLUGIN_TNTSEARCH:
18+
FOUND_RESULTS: "Résultats trouvés: %s"
19+
FOUND_IN: "(<span>%s</span>)"
20+
POWERED_BY: "Par %s"

tntsearch.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ built_in_search_page: true
77
enable_admin_page_events: true
88
search_type: auto
99
fuzzy: false
10+
distance: 2
1011
phrases: true
1112
stemmer: default
1213
display_route: true

vendor/autoload.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
// autoload.php @generated by Composer
44

5+
if (PHP_VERSION_ID < 50600) {
6+
if (!headers_sent()) {
7+
header('HTTP/1.1 500 Internal Server Error');
8+
}
9+
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10+
if (!ini_get('display_errors')) {
11+
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12+
fwrite(STDERR, $err);
13+
} elseif (!headers_sent()) {
14+
echo $err;
15+
}
16+
}
17+
trigger_error(
18+
$err,
19+
E_USER_ERROR
20+
);
21+
}
22+
523
require_once __DIR__ . '/composer/autoload_real.php';
624

725
return ComposerAutoloaderInit6693564509f9a3fa6ed2c7bf76fdb017::getLoader();

0 commit comments

Comments
 (0)