jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/351302 )
Change subject: ExtendedSearch: Fix for sending multiple namespace params to Solr ...................................................................... ExtendedSearch: Fix for sending multiple namespace params to Solr When term is typed into autocomplete box search query is created with default namespaces to be searched. But when term with namespace already in is typed in 'namespace' key is added again, causing missed matches. Now default namespaces are added only if no explicit NS is detected Needs cherry-picking to REL1_27 and REL1_23 Change-Id: I9507a8e0eaac1e63b9f5ddfe0fcf9cad60f706d6 ERM: #6247 --- M ExtendedSearch/includes/SearchIndex/SearchOptions.class.php 1 file changed, 18 insertions(+), 18 deletions(-) Approvals: Robert Vogel: Looks good to me, approved jenkins-bot: Verified diff --git a/ExtendedSearch/includes/SearchIndex/SearchOptions.class.php b/ExtendedSearch/includes/SearchIndex/SearchOptions.class.php index 47c15fc..cd2c309 100644 --- a/ExtendedSearch/includes/SearchIndex/SearchOptions.class.php +++ b/ExtendedSearch/includes/SearchIndex/SearchOptions.class.php @@ -184,14 +184,10 @@ public function getSolrAutocompleteQuery( $sSearchString, $sSolrSearchString ) { $aSearchOptions = array(); $aSearchOptions['fl'] = 'type,title,namespace'; - $aSearchOptions['fq'] = $this->makeAutoCompleteFilterQuery(); + $aSearchOptionsFq = array(); + $vNamespace = $this->makeAutoCompleteFilterQuery( $sSearchString, $sSolrSearchString, $aSearchOptionsFq ); + $aSearchOptions['fq'] = $aSearchOptionsFq; $aSearchOptions['sort'] = $this->aSearchOptions['sort']; - - $vNamespace = $this->checkSearchstringForNamespace( - $sSearchString, - $sSolrSearchString, - $aSearchOptions['fq'] - ); $aOptions = array(); $sWildcardedSearchString = SearchService::wildcardSearchstring( $sSolrSearchString ); @@ -619,19 +615,23 @@ $this->aFacetFields[] = $sFacetField; } - protected function makeAutoCompleteFilterQuery() { - $oUser = RequestContext::getMain()->getUser(); - $aOptions = $oUser->getOptions(); - $aNamespaces = [ 1000 ]; //For some strange reason 1000 is NS_SPECIAL within the SOLR index - foreach ( $aOptions as $sOpt => $sValue ) { - if ( strpos( $sOpt, 'searchNs' ) !== false && $sValue == true ) { - $aNamespaces[] = '' . str_replace( 'searchNs', '', $sOpt ); + protected function makeAutoCompleteFilterQuery( $sSearchString, &$sSolrSearchString, &$aSearchOptionsFq ) { + $vNamespace = $this->checkSearchstringForNamespace( $sSearchString, $sSolrSearchString, $aSearchOptionsFq ); + + if( empty( $aSearchOptionsFq ) ) { + $oUser = RequestContext::getMain()->getUser(); + $aOptions = $oUser->getOptions(); + $aNamespaces = [ 1000 ]; //For some strange reason 1000 is NS_SPECIAL within the SOLR index + foreach ( $aOptions as $sOpt => $sValue ) { + if ( strpos( $sOpt, 'searchNs' ) !== false && $sValue == true ) { + $aNamespaces[] = '' . str_replace( 'searchNs', '', $sOpt ); + } } + $aSearchOptionsFq[] = 'namespace:("'.implode( '" OR "', $aNamespaces ).'")'; } - return array( - 'wiki:(' . $this->getCustomerId() . ')', - 'namespace:("'.implode( '" OR "', $aNamespaces ).'")' - ); + $aSearchOptionsFq[] = 'wiki:(' . $this->getCustomerId() . ')'; + + return $vNamespace; } } -- To view, visit https://gerrit.wikimedia.org/r/351302 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9507a8e0eaac1e63b9f5ddfe0fcf9cad60f706d6 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions Gerrit-Branch: master Gerrit-Owner: ItSpiderman <d.savulje...@gmail.com> Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits