mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-25 05:22:59 +00:00
Squash all the error messages, but it's not working as intended.
All that seems to have happened is that searches are taking longer and not doing anything different.....
This commit is contained in:
parent
f632c0907c
commit
d131666ff5
2 changed files with 20 additions and 8 deletions
|
@ -316,6 +316,8 @@ register_module([
|
|||
$result->time_format = "ms";
|
||||
$result->decode_time = $env->perfdata->searchindex_decode_time;
|
||||
$result->query_time = $env->perfdata->searchindex_query_time;
|
||||
if(isset($env->perfdata->didyoumean_correction))
|
||||
$result->didyoumean_correction_time = $env->perfdata->didyoumean_correction;
|
||||
$result->total_time = $result->decode_time + $result->query_time;
|
||||
$result->stas = search::stas_parse(search::stas_split($_GET["query"]));
|
||||
$result->search_results = $searchResults;
|
||||
|
@ -342,12 +344,6 @@ register_module([
|
|||
exit(page_renderer::render_main("Error - STAS Query Analysis - $settings->sitename", "<p>No query was present in the <code>query</code> GET parameter.</p>"));
|
||||
}
|
||||
|
||||
// The indexes are only needed if didyoumean is enabled
|
||||
if(module_exists("feature-search-didyoumean") && $settings->search_didyoumean_enabled) {
|
||||
search::invindex_load();
|
||||
search::didyoumean_load();
|
||||
}
|
||||
|
||||
$tokens = search::stas_split($_GET["query"]);
|
||||
$stas_query = search::stas_parse($tokens);
|
||||
|
||||
|
|
|
@ -170,7 +170,18 @@ class search
|
|||
* @return string|null The closest correction found, or null if none could be located.
|
||||
*/
|
||||
public static function didyoumean_correct(string $term) : ?string {
|
||||
global $settings;
|
||||
global $settings, $paths, $env;
|
||||
|
||||
$start_time = microtime(true);
|
||||
|
||||
// Load the didyoumean index, but only if it's enabled etc
|
||||
if(!module_exists("feature-search-didyoumean") || !$settings->search_didyoumean_enabled)
|
||||
return null;
|
||||
|
||||
// If it's not loaded already, load the didyoumean index on-demand
|
||||
if(self::$didyoumeanindex == null)
|
||||
search::didyoumean_load($paths->searchindex);
|
||||
|
||||
$results = self::$didyoumeanindex->lookup(
|
||||
$term,
|
||||
$settings->search_didyoumean_editdistance
|
||||
|
@ -179,6 +190,10 @@ class search
|
|||
usort($results, function($a, $b) : int {
|
||||
return self::compare($a, $b);
|
||||
});
|
||||
|
||||
if(!isset($env->perfdata->didyoumean_correction))
|
||||
$env->perfdata->didyoumean_correction = 0;
|
||||
$env->perfdata->didyoumean_correction += (microtime(true) - $start_time) * 1000;
|
||||
return $results[0];
|
||||
}
|
||||
|
||||
|
@ -664,7 +679,8 @@ class search
|
|||
self::invindex_term_exists($term_data["term"])) continue;
|
||||
|
||||
// It's not a stop word or in the index, try and correct it
|
||||
$correction = self::didyoumean_correct($termdata["term"]);
|
||||
// self::didyoumean_correct auto-loads the didyoumean index on-demand
|
||||
$correction = self::didyoumean_correct($term_data["term"]);
|
||||
// Make a note if we fail to correct a term
|
||||
if(!is_string($correction)) {
|
||||
$term_data["corrected"] = false;
|
||||
|
|
Loading…
Reference in a new issue