jenkins-bot has submitted this change and it was merged.
Change subject: Quotes turn off stemming.
......................................................................
Quotes turn off stemming.
Wrap something quotes to get a more specific match that also payes
attention to stop words. This is a reimplementation of something in
MWSearch.
Unlike MWSearch you can turn stemming back on in a phrase search:
"foo bar" - no stemming, matches stop words
"foo bar"~ - stemming and ignores stop words
"foo bar"~3 - no stemming, matches stop words, has a phrase slop of 3
"foo bar"~3~ - stemming and ignores stop words, has a phrase slop of 3
This change comes at a price: 54526.
Bug: 54020
Change-Id: I934c98d8245b2b52f9d432d71ef3f6adaa0c2bca
---
M CirrusSearchSearcher.php
1 file changed, 16 insertions(+), 1 deletion(-)
Approvals:
Chad: Looks good to me, approved
jenkins-bot: Verified
diff --git a/CirrusSearchSearcher.php b/CirrusSearchSearcher.php
index 87bf29e..7e9dee1 100644
--- a/CirrusSearchSearcher.php
+++ b/CirrusSearchSearcher.php
@@ -139,6 +139,21 @@
},
$term
);
+ $term = preg_replace_callback(
+ '/(?<main>"([^"]+)"(?:~[0-9]+)?)(?<fuzzy>~)?/',
+ function ( $matches ) use ( $showRedirects,
&$extraQueryStrings ) {
+ $main = $matches[ 'main' ];
+ if ( isset( $matches[ 'fuzzy' ] ) ) {
+ return $main;
+ } else {
+ $query = join( ' OR ',
+
CirrusSearchSearcher::buildFullTextSearchFields( $showRedirects, ".plain:$main"
) );
+ $extraQueryStrings[] =
"($query)";
+ }
+ return '';
+ },
+ $term
+ );
$this->filters = $filters;
// Actual text query
@@ -428,7 +443,7 @@
return $matches[ 'leading' ] . '\\~' .
$matches[ 'trailing' ];
}
}, $string );
- // Turn bad proximity searches into seraches that contain a ~
+ // Turn bad proximity searches into searches that contain a ~
$string = preg_replace_callback( '/"~(?<trailing>\S*)/',
function ( $matches ) {
if ( preg_match( '/[0-9]+/', $matches[ 'trailing' ] ) )
{
return $matches[ 0 ];
--
To view, visit https://gerrit.wikimedia.org/r/85908
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I934c98d8245b2b52f9d432d71ef3f6adaa0c2bca
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits