EBernhardson has uploaded a new change for review. https://gerrit.wikimedia.org/r/307954
Change subject: Do not use the suggest reverse field if it's a non local search ...................................................................... Do not use the suggest reverse field if it's a non local search We do not know if the reverse field is available on extra indices. We should not use it for such queries. Change-Id: Ia88618f38ad39ee58ed07b291f1b1ed67debd54a (cherry picked from commit e1cc2624243b3e9960428c9646bec1a13ea5d9b8) --- M includes/Query/FullTextQueryStringQueryBuilder.php 1 file changed, 15 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/54/307954/1 diff --git a/includes/Query/FullTextQueryStringQueryBuilder.php b/includes/Query/FullTextQueryStringQueryBuilder.php index 9f22dfd..45decbb 100644 --- a/includes/Query/FullTextQueryStringQueryBuilder.php +++ b/includes/Query/FullTextQueryStringQueryBuilder.php @@ -2,6 +2,7 @@ namespace CirrusSearch\Query; +use CirrusSearch\OtherIndexes; use CirrusSearch\SearchConfig; use CirrusSearch\Searcher; use CirrusSearch\Search\Escaper; @@ -222,7 +223,7 @@ if ( $showSuggestion ) { $searchContext->setSuggest( [ 'text' => $term, - 'suggest' => $this->buildSuggestConfig( 'suggest' ), + 'suggest' => $this->buildSuggestConfig( 'suggest', $searchContext ), ] ); } } @@ -259,9 +260,10 @@ * Build suggest config for $field. * * @param string $field field to suggest against + * @param SearchContext $searchContext * @return array[] array of Elastica configuration */ - private function buildSuggestConfig( $field ) { + private function buildSuggestConfig( $field, $searchContext ) { // check deprecated settings $suggestSettings = $this->config->get( 'CirrusSearchPhraseSuggestSettings' ); $maxErrors = $this->config->get( 'CirrusSearchPhraseSuggestMaxErrors' ); @@ -295,8 +297,18 @@ ], ], ]; + $extraIndexes = null; + if ( $searchContext->getNamespaces() ) { + $extraIndexes = OtherIndexes::getExtraIndexesForNamespaces( + $searchContext->getNamespaces() + ); + } // Add a second generator with the reverse field - if ( $this->config->getElement( 'CirrusSearchPhraseSuggestReverseField', 'use' ) ) { + // Only do this for local queries, we don't know if it's activated + // on other wikis. + if ( empty( $extraIndexes ) + && $this->config->getElement( 'CirrusSearchPhraseSuggestReverseField', 'use' ) + ) { $settings['phrase']['direct_generator'][] = [ 'field' => $field . '.reverse', 'suggest_mode' => $suggestSettings['mode'], -- To view, visit https://gerrit.wikimedia.org/r/307954 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia88618f38ad39ee58ed07b291f1b1ed67debd54a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: wmf/1.28.0-wmf.16 Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: DCausse <dcau...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits