jenkins-bot has submitted this change and it was merged.
Change subject: Remove support for float fuzziness
......................................................................
Remove support for float fuzziness
Float fuzziness was removed in lucene 5, so we can no longer support it
in elasticsearch 2.x.
Bug: T133750
Change-Id: I05aa297465451bcbc6564845fb4cd1eb9c0c0cad
---
M includes/Search/Escaper.php
M tests/browser/features/fuzzy_api.feature
M tests/unit/Search/EscaperTest.php
3 files changed, 28 insertions(+), 4 deletions(-)
Approvals:
DCausse: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Search/Escaper.php b/includes/Search/Escaper.php
index 2d20fd3..960c20f 100644
--- a/includes/Search/Escaper.php
+++ b/includes/Search/Escaper.php
@@ -123,7 +123,7 @@
$fuzzyQuery = false;
$string = preg_replace_callback(
'/(?<leading>\w)~(?<trailing>\S*)/u',
function ( $matches ) use ( &$fuzzyQuery ) {
- if ( preg_match(
'/^(?:|0|0?\.\d+|1(?:\.0)?)$/', $matches[ 'trailing' ] ) ) {
+ if ( preg_match( '/^(|[0-2])$/', $matches[
'trailing' ] ) ) {
$fuzzyQuery = true;
return $matches[ 0 ];
} else {
diff --git a/tests/browser/features/fuzzy_api.feature
b/tests/browser/features/fuzzy_api.feature
index e488899..6f1817f 100644
--- a/tests/browser/features/fuzzy_api.feature
+++ b/tests/browser/features/fuzzy_api.feature
@@ -16,12 +16,11 @@
When I api search for ffnonesensewor~
Then Two Words is the first api search result
- Scenario Outline: Searching for <text>~<number between 0 and 1> activates
fuzzy search
+ Scenario Outline: Searching for <text>~<number> activates fuzzy search
When I api search for ffnonesensewor~<number>
Then Two Words is the first api search result
Examples:
| number |
- | .8 |
- | 0.8 |
| 1 |
+ | 2 |
diff --git a/tests/unit/Search/EscaperTest.php
b/tests/unit/Search/EscaperTest.php
index c4690a4..e7fccf9 100644
--- a/tests/unit/Search/EscaperTest.php
+++ b/tests/unit/Search/EscaperTest.php
@@ -23,6 +23,31 @@
* http://www.gnu.org/copyleft/gpl.html
*/
class EscaperTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @dataProvider fuzzyEscapeTestCases
+ */
+ public function testFuzzyEscape( $input, $expected, $isFuzzy ) {
+ $escaper = new Escaper( 'unittest' );
+ $actual = $escaper->fixupWholeQueryString( $input );
+ $this->assertEquals( array( $expected, $isFuzzy), $actual );
+ }
+
+ public static function fuzzyEscapeTestCases() {
+ return array(
+ 'Default fuzziness is allowed' => array( 'fuzzy~',
'fuzzy~', true ),
+ 'No fuzziness is allowed' => array( 'fuzzy~0',
'fuzzy~0', true ),
+ 'One char edit distance is allowed' => array(
'fuzzy~1', 'fuzzy~1', true ),
+ 'Two char edit distance is allowed' => array(
'fuzzy~2', 'fuzzy~2', true ),
+ 'Three char edit distance is disallowed' => array(
'fuzzy~3', 'fuzzy\\~3', false ),
+ 'non-integer edit distance is disallowed' => array(
'fuzzy~1.0', 'fuzzy\\~1.0', false ),
+ 'Larger edit distances are disallowed' => array(
'fuzzy~10', 'fuzzy\\~10', false ),
+ 'Proximity searches are allowed' => array( '"fuzzy
wuzzy"~10', '"fuzzy wuzzy"~10', false ),
+ 'Float fuzziness with leading 0 is disallowed' =>
array( 'fuzzy~0.8', 'fuzzy\\~0.8', false ),
+ 'Float fuzziness is disallowed' => array( 'fuzzy~.8',
'fuzzy\\~.8', false ),
+ );
+ }
+
/**
* @dataProvider quoteEscapeTestCases
*/
--
To view, visit https://gerrit.wikimedia.org/r/286511
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I05aa297465451bcbc6564845fb4cd1eb9c0c0cad
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: es2.x
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits