jenkins-bot has submitted this change and it was merged. Change subject: Stop prefix: filter from searching redirects ......................................................................
Stop prefix: filter from searching redirects Even though it is named after regular prefix searches, we don't want it to search redirects. Mostly, we don't want it to to that because people don't expect it to. Additionally, it is _very_ hard to figure out what is going on because the prefix filter doesn't get highlighted. Bug: 65232 Change-Id: I8c155f189c068631828faa59e1a84610eeba68a5 --- M includes/Searcher.php M tests/browser/features/prefix.feature M tests/browser/features/support/hooks.rb 3 files changed, 11 insertions(+), 14 deletions(-) Approvals: Chad: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Searcher.php b/includes/Searcher.php index b9602cd..ea281aa 100644 --- a/includes/Searcher.php +++ b/includes/Searcher.php @@ -230,7 +230,9 @@ } else { // Elasticsearch seems to have trouble extracting the proper terms to highlight // from the default query we make so we feed it exactly the right query to highlight. - $this->highlightQuery = $this->buildPrefixQuery( $search ); + $this->highlightQuery = new \Elastica\Query\MultiMatch(); + $this->highlightQuery->setQuery( $search ); + $this->highlightQuery->setFields( array( 'title.prefix', 'redirect.title.prefix' ) ); $this->filters[] = new \Elastica\Filter\Query( $this->highlightQuery ); } $this->boostTemplates = self::getDefaultBoostTemplates(); @@ -290,7 +292,9 @@ // If the namespace prefix wasn't the entire prefix filter then add a filter for the title if ( strpos( $value, ':' ) !== strlen( $value ) - 1 ) { $value = str_replace( '_', ' ', $value ); - $this->filters[] = new \Elastica\Filter\Query( $this->buildPrefixQuery( $value ) ); + $prefixQuery = new \Elastica\Query\Match(); + $prefixQuery->setFieldQuery( 'title.prefix', $value ); + $this->filters[] = new \Elastica\Filter\Query( $prefixQuery ); } } } @@ -981,18 +985,6 @@ array( 'local_sites_with_dupe' => wfWikiId() ) ); } return $extraIndexes; - } - - /** - * Build the query that powers the prefix search and the prefix filter. - * @param string $search prefix search string - * @return \Elastica\AbstractQuery to perform the query - */ - private function buildPrefixQuery( $search ) { - $match = new \Elastica\Query\MultiMatch(); - $match->setQuery( $search ); - $match->setFields( array( 'title.prefix', 'redirect.title.prefix' ) ); - return $match; } /** diff --git a/tests/browser/features/prefix.feature b/tests/browser/features/prefix.feature index c1ce9e5..eb73b4c 100644 --- a/tests/browser/features/prefix.feature +++ b/tests/browser/features/prefix.feature @@ -64,3 +64,7 @@ When I search for prefix test prefix:"user_talk:" Then User talk:Prefix Test is the first search result But Prefix Test is not in the search results + + Scenario: The prefix: filter doesn't find redirects + When I search for prefix:Prefix Test Redirec + Then there are no search results \ No newline at end of file diff --git a/tests/browser/features/support/hooks.rb b/tests/browser/features/support/hooks.rb index f2a0335..ed35210 100644 --- a/tests/browser/features/support/hooks.rb +++ b/tests/browser/features/support/hooks.rb @@ -234,6 +234,7 @@ if !$prefix_filter steps %Q{ Given a page named Prefix Test exists + And a page named Prefix Test Redirect exists with contents #REDIRECT [[Prefix Test]] And a page named Foo Prefix Test exists with contents [[Prefix Test]] And a page named Prefix Test/AAAA exists with contents [[Prefix Test]] And a page named Prefix Test AAAA exists with contents [[Prefix Test]] -- To view, visit https://gerrit.wikimedia.org/r/132973 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8c155f189c068631828faa59e1a84610eeba68a5 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: Manybubbles <never...@wikimedia.org> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Manybubbles <never...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits