1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 16:33:00 +00:00

Fix intitle: & intags: syntax - game, set, match.

This commit is contained in:
Starbeamrainbowlabs 2019-08-22 22:23:30 +01:00
parent 9505e0653e
commit 4d51ae924e
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 6 additions and 4 deletions

View file

@ -135,7 +135,7 @@
"version": "0.10", "version": "0.10",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.", "description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
"lastupdate": 1566508042, "lastupdate": 1566508630,
"optional": false, "optional": false,
"extra_data": [] "extra_data": []
}, },

View file

@ -1003,6 +1003,8 @@ class search
* @param string[] $tokens The array of query tokens to parse. * @param string[] $tokens The array of query tokens to parse.
*/ */
public function stas_parse($tokens) { public function stas_parse($tokens) {
global $settings;
/* Supported Syntax * /* Supported Syntax *
* *
* -term exclude a term * -term exclude a term
@ -1173,7 +1175,7 @@ class search
foreach($query_stas["terms"] as $term_def) { foreach($query_stas["terms"] as $term_def) {
// No need to skip stop words here, since we're doing a normal // No need to skip stop words here, since we're doing a normal
// sequential search anyway // sequential search anyway
if(!in_array($term_def["location"], ["all", "intitle", "intags"])) if(!in_array($term_def["location"], ["all", "title", "tags"]))
continue; // Skip terms we shouldn't search the page body for continue; // Skip terms we shouldn't search the page body for
// Loop over the pageindex and search the titles / tags // Loop over the pageindex and search the titles / tags
@ -1199,7 +1201,7 @@ class search
if($skip) continue; if($skip) continue;
// Consider matches in the page title // Consider matches in the page title
if(in_array($term_def["location"], ["all", "intitle"])) { if(in_array($term_def["location"], ["all", "title"])) {
// FUTURE: We may be able to optimise this further by using preg_match_all + preg_quote instead of mb_stripos_all. Experimentation / benchmarking is required to figure out which one is faster // FUTURE: We may be able to optimise this further by using preg_match_all + preg_quote instead of mb_stripos_all. Experimentation / benchmarking is required to figure out which one is faster
$title_matches = mb_stripos_all($lit_title, $term_def["term"]); $title_matches = mb_stripos_all($lit_title, $term_def["term"]);
$title_matches_count = $title_matches !== false ? count($title_matches) : 0; $title_matches_count = $title_matches !== false ? count($title_matches) : 0;
@ -1217,7 +1219,7 @@ class search
if($lit_tags == null) if($lit_tags == null)
continue; continue;
if(!in_array($term_def["location"], ["all", "intags"])) if(!in_array($term_def["location"], ["all", "tags"]))
continue; // If we shouldn't search the tags, no point in continuing continue; // If we shouldn't search the tags, no point in continuing
// Consider matches in the page's tags // Consider matches in the page's tags