Manybubbles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/118651

Change subject: Use combined didyoumean
......................................................................

Use combined didyoumean

Change-Id: I29c4bc812fe2cda70c670618ce9cc7edde4f3883
---
M includes/ResultSet.php
M includes/Searcher.php
2 files changed, 4 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/51/118651/1

diff --git a/includes/ResultSet.php b/includes/ResultSet.php
index de2c197..335a1cd 100644
--- a/includes/ResultSet.php
+++ b/includes/ResultSet.php
@@ -60,20 +60,9 @@
                $suggest = $suggest[ 'suggest' ];
                // Elasticsearch will send back the suggest element but no sub 
suggestion elements if the wiki is empty.
                // So we should check to see if they exist even though in 
normal operation they always will.
-               if ( isset( $suggest[ Searcher::SUGGESTION_NAME_TITLE ] ) ) {
-                       foreach ( $suggest[ Searcher::SUGGESTION_NAME_TITLE ][ 
0 ][ 'options' ] as $option ) {
-                               return $option;
-                       }
-               }
-               // If the user doesn't search against redirects we don't check 
them for suggestions so the result might not be there.
-               if ( isset( $suggest[ Searcher::SUGGESTION_NAME_REDIRECT ] ) ) {
-                       foreach ( $suggest[ Searcher::SUGGESTION_NAME_REDIRECT 
][ 0 ][ 'options' ] as $option ) {
-                               return $option;
-                       }
-               }
-               // This suggestion type is optional, configured in 
LocalSettings.
-               if ( isset( $suggest[ Searcher::SUGGESTION_NAME_TEXT ] ) ) {
-                       foreach ( $suggest[ Searcher::SUGGESTION_NAME_TEXT ][ 0 
][ 'options' ] as $option ) {
+               if ( isset( $suggest[ 'suggest' ] ) ) {
+                       // Now just grab the first one it sent back.
+                       foreach ( $suggest[ 'suggest' ][ 0 ][ 'options' ] as 
$option ) {
                                return $option;
                        }
                }
diff --git a/includes/Searcher.php b/includes/Searcher.php
index 65ce7e8..577dea0 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -31,9 +31,6 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 class Searcher extends ElasticsearchIntermediary {
-       const SUGGESTION_NAME_TITLE = 'title';
-       const SUGGESTION_NAME_REDIRECT = 'redirect';
-       const SUGGESTION_NAME_TEXT = 'text_suggestion';
        const SUGGESTION_HIGHLIGHT_PRE = '<em>';
        const SUGGESTION_HIGHLIGHT_POST = '</em>';
        const HIGHLIGHT_PRE = '<span class="searchmatch">';
@@ -485,14 +482,8 @@
                        if ( $showSuggestion ) {
                                $this->suggest = array(
                                        'text' => $this->term,
-                                       self::SUGGESTION_NAME_TITLE => 
$this->buildSuggestConfig( 'title.suggest' ),
+                                       'suggest' => $this->buildSuggestConfig( 
'suggest' ),
                                );
-                               if ( $showRedirects ) {
-                                       $this->suggest[ 
self::SUGGESTION_NAME_REDIRECT ] = $this->buildSuggestConfig( 
'redirect.title.suggest' );
-                               }
-                               if ( $wgCirrusSearchPhraseUseText ) {
-                                       $this->suggest[ 
self::SUGGESTION_NAME_TEXT ] = $this->buildSuggestConfig( 'text.suggest' );
-                               }
                        }
                        wfProfileOut( __METHOD__ . '-build-query' );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/118651
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I29c4bc812fe2cda70c670618ce9cc7edde4f3883
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

Reply via email to