From e6aefdadb74e2b4921765f952d65b9ed7c6872b8 Mon Sep 17 00:00:00 2001 From: Aria <aria@suma-aria> Date: Mon, 14 Oct 2019 12:58:34 +0200 Subject: [PATCH] only query parts which are not inside of phrase searches will be checked for stopwords --- app/MetaGer.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/MetaGer.php b/app/MetaGer.php index e2c12c768..cb5f1c91f 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -1098,6 +1098,7 @@ class MetaGer $tmp = $match[1] . $match[3]; $this->phrases[] = $match[2]; } + foreach ($this->phrases as $phrase) { $p .= "\"$phrase\", "; } @@ -1197,8 +1198,16 @@ class MetaGer private function searchCheckStopwords($request) { $oldQ = $this->q; + + $tmp = $this->q; + // matches '[... ]"test satz"[ ...]' + // In order to avoid "finding" stopwords inside of phrase searches only strings outside of quotation marks should be checked + while (preg_match("/(^|.*?\s)\"(.+)\"(\s.*|$)/si", $tmp, $match)) { + $tmp = $match[1] . $match[3]; + } + // matches '[... ]-test[ ...]' - $words = preg_split("/\s+/si", $this->q); + $words = preg_split("/\s+/si", $tmp); $newQ = ""; foreach ($words as $word) { if (strpos($word, "-") === 0 && strlen($word) > 1) { -- GitLab