Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default stemmer (again) #116

Merged
merged 2 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ enable_admin_page_events: true
search_type: auto
fuzzy: false
phrases: true
stemmer: default
stemmer: 'no'
display_route: true
display_hits: true
display_time: true
Expand Down Expand Up @@ -105,7 +105,6 @@ The configuration options are as follows:
* `fuzzy` - matches if the words are 'close' but not necessarily exact matches
* `phrases` - automatically handle phrases support
* `stemmer` - can be one of these types:
* `default` - Porter stemmer for English language
* `no` - no stemmer
* `arabic` - Arabic language
* `german` - German language
Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ form:
classes: fancy
label: Stemmer
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.
default: no
options:
default: Default (English)
no: Disabled
arabic: Arabic
porter: English
Expand Down
8 changes: 5 additions & 3 deletions classes/GravTNTSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($options = [])
$locator = Grav::instance()['locator'];

$search_type = $config->get('plugins.tntsearch.search_type', 'auto');
$stemmer = $config->get('plugins.tntsearch.stemmer', 'default');
$stemmer = $config->get('plugins.tntsearch.stemmer', 'no');
$limit = $config->get('plugins.tntsearch.limit', 20);
$snippet = $config->get('plugins.tntsearch.snippet', 300);
$data_path = $locator->findResource('user://data', true) . '/tntsearch';
Expand Down Expand Up @@ -225,8 +225,10 @@ public function createIndex()
$this->tnt->setDatabaseHandle(new GravConnector);
$indexer = $this->tnt->createIndex($this->index);

// Set the stemmer language if set
if ($this->options['stemmer'] !== 'default') {
// Disable stemmer for users with older configuration.
if ($this->options['stemmer'] == 'default') {
$indexer->setLanguage('no');
} else {
$indexer->setLanguage($this->options['stemmer']);
}

Expand Down