Skip to content

Commit

Permalink
Merge branch 'release/3.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Mar 6, 2023
2 parents f28ca5d + 1a9d514 commit b4560aa
Show file tree
Hide file tree
Showing 50 changed files with 1,845 additions and 497 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# v3.4.0
## 03/06/2023

1. [](#improved)
* Updated TNTSearch library to `2.9.0`
* Enable Fuzy search [#123](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/123)
* Add configuration for Levenshtein distance for fuzzy search [#124](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/124)
* Added French translation [#100](https://github.com/trilbymedia/grav-plugin-tntsearch/issues/100)
* Added missing stemmers [#115](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/115) [#116](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/116)

# v3.3.1
## 02/25/2021

Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ built_in_search_page: true
enable_admin_page_events: true
search_type: auto
fuzzy: false
distance: 2
phrases: true
stemmer: default
stemmer: 'no'
display_route: true
display_hits: true
display_time: true
Expand Down Expand Up @@ -103,14 +104,16 @@ The configuration options are as follows:
* `boolean` - supports `or` or `minus`. e.g. `foo -bar`
* `auto` - automatically detects whether to use `basic` or `boolean`
* `fuzzy` - matches if the words are 'close' but not necessarily exact matches
* `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.
* `phrases` - automatically handle phrases support
* `stemmer` - can be one of these types:
* `default` - Porter stemmer for English language
* `no` - no stemmer
* `arabic` - Arabic language
* `croatian` - Croatian language
* `german` - German language
* `italian` - Italian language
* `porter` - Porter stemmer for English language
* `portuguese` - Portuguese language
* `russian` - Russian language
* `ukrainian` - Ukrainian language
* `display_route` - display the route in the search results
Expand Down
15 changes: 12 additions & 3 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: TNT Search
type: plugin
slug: tntsearch
version: 3.3.1
version: 3.4.0
testing: false
description: Powerful indexed-based full text search engine powered by TNTSearch
icon: binoculars
Expand Down Expand Up @@ -150,13 +150,20 @@ form:
type: toggle
label: Fuzzy Search
highlight: 1
default: 1
default: 0
options:
1: Enabled
0: Disabled
validate:
type: bool

distance:
type: number
size: x-small
label: Levenshtein distance of fuzzy search
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.
default: 2

phrases:
type: toggle
label: Match quoted phrases
Expand All @@ -174,13 +181,15 @@ 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
croatian: Croatian
porter: English
german: German
italian: Italian
portuguese: Portuguese
russian: Russian
ukrainian: Ukrainian

Expand Down
13 changes: 10 additions & 3 deletions classes/GravTNTSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public function __construct($options = [])
$locator = Grav::instance()['locator'];

$search_type = $config->get('plugins.tntsearch.search_type', 'auto');
$stemmer = $config->get('plugins.tntsearch.stemmer', 'default');
$fuzzy = $config->get('plugins.tntsearch.fuzzy', false);
$distance = $config->get('plugins.tntsearch.distance', 2);
$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 All @@ -64,6 +66,8 @@ public function __construct($options = [])
$defaults = [
'json' => false,
'search_type' => $search_type,
'fuzzy' => $fuzzy,
'distance' => $distance,
'stemmer' => $stemmer,
'limit' => $limit,
'as_you_type' => true,
Expand Down Expand Up @@ -97,6 +101,7 @@ public function search($query)

if (isset($this->options['fuzzy']) && $this->options['fuzzy']) {
$this->tnt->fuzziness = true;
$this->tnt->fuzzy_distance = $this->options['distance'];
}

$limit = (int)$this->options['limit'];
Expand Down Expand Up @@ -225,8 +230,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
25 changes: 13 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ ru:
FOUND_RESULTS: "Результатов: %s"
FOUND_IN: "(<span>%s</span>)"
POWERED_BY: "Работает на %s"
fr:
PLUGIN_TNTSEARCH:
FOUND_RESULTS: "Résultats trouvés: %s"
FOUND_IN: "(<span>%s</span>)"
POWERED_BY: "Par %s"
1 change: 1 addition & 0 deletions tntsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ built_in_search_page: true
enable_admin_page_events: true
search_type: auto
fuzzy: false
distance: 2
phrases: true
stemmer: default
display_route: true
Expand Down
18 changes: 18 additions & 0 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$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;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit6693564509f9a3fa6ed2c7bf76fdb017::getLoader();
Loading

0 comments on commit b4560aa

Please sign in to comment.