Manybubbles has uploaded a new change for review.
https://gerrit.wikimedia.org/r/161474
Change subject: Fix multiple phrase queries in same search
......................................................................
Fix multiple phrase queries in same search
We were merging all the phrase queries into a single one - this is obviously
wrong.
Change-Id: I9599bd20a9f48aabe60e9634ac4d13d8db02ddd2
---
M includes/Searcher.php
M tests/browser/features/exact_quotes.feature
2 files changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/74/161474/1
diff --git a/includes/Searcher.php b/includes/Searcher.php
index bd78012..6af09c2 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -546,7 +546,7 @@
// Those phrases can optionally be followed by ~ then a number
(this is the phrase slop)
// That can optionally be followed by a ~ (this matches stemmed
words in phrases)
// The following all match: "a", "a boat", "a\"boat", "a
boat"~, "a boat"~9, "a boat"~9~, -"a boat", -"a boat"~9~
- $query = self::replacePartsOfQuery( $this->term,
'/(?<![\]])(?<negate>-|!)?(?<main>"((?:[^"]|(?:\"))+)"(?<slop>~[0-9]+)?)(?<fuzzy>~)?/',
+ $query = self::replacePartsOfQuery( $this->term,
'/(?<![\]])(?<negate>-|!)?(?<main>"((?:[^"]|(?:\\\"))+)"(?<slop>~[0-9]+)?)(?<fuzzy>~)?/',
function ( $matches ) use ( $searcher, $escaper,
&$phrases ) {
global $wgCirrusSearchPhraseSlop;
$negate = $matches[ 'negate' ][ 0 ] ? 'NOT ' :
'';
diff --git a/tests/browser/features/exact_quotes.feature
b/tests/browser/features/exact_quotes.feature
index 682fcb9..414cca9 100644
--- a/tests/browser/features/exact_quotes.feature
+++ b/tests/browser/features/exact_quotes.feature
@@ -86,3 +86,13 @@
| - | ~7~ |
| ! | ~7~ |
| %{exact:NOT } | ~7~ |
+
+ Scenario: Can combine positive and negative phrase search
+ When I search for catapult "catapult" -"two words" -"some stuff"
+ Then Catapult is in the search results
+ And Two Words is not in the search results
+
+ Scenario: Can combine positive and negative phrase search (backwards)
+ When I search for catapult -"asdf" "two words"
+ Then Two Words is in the search results
+ And Catapult is not in the search results
--
To view, visit https://gerrit.wikimedia.org/r/161474
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9599bd20a9f48aabe60e9634ac4d13d8db02ddd2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits