Topic on Project:Support desk

Namespace results in search suggestions.

4
Valadez (talkcontribs)

I'm trying to configure my search box to include content pages from two namespaces as suggestions. I've added the namespaces to $wgNamespacesToBeSearchedDefault which works correctly in regular search and also enabled $wgEnableMWSuggest which also works. There is a topic in the Manual:$wgEnableMWSuggest talk page that seems to indicate that this isn't possible but it's been done over at UESP.net. Does anyone know how to do this? If it helps this is the wiki and here is an example search that includes both namespaces in the search results. Thanks in advance.

MarkAHershberger (talkcontribs)
Valadez (talkcontribs)

Thanks for looking into it. Explains why I haven't seen it anywhere else. I'll keep an eye on on Daveh's talk page as well.

2001:1AB8:2:0:47F:24FA:8FAE:8103 (talkcontribs)

I know this is old, but I've found a solution.


Edit your resources\src\mediawiki\mediawiki.searchSuggest.js

Change from:

( function ( mw, $ ) {

mw.searchSuggest = {

// queries the wiki and calls response with the result

request: function ( api, query, response, maxRows, namespace ) {

return api.get( {

formatversion: 2,

action: 'opensearch',

search: query,

namespace: namespace || '0',

limit: maxRows,

suggest: true

} ).done( function ( data, jqXHR ) {

response( data[ 1 ], {

type: jqXHR.getResponseHeader( 'X-OpenSearch-Type' ),

query: query

} );

} );

}

};

To:

( function ( mw, $ ) {

mw.searchSuggest = {

// queries the wiki and calls response with the result

request: function ( api, query, response, maxRows, namespace ) {

return api.get( {

formatversion: 2,

action: 'opensearch',

search: query,

namespace: namespace || '0|3010',

limit: maxRows,

suggest: true

} ).done( function ( data, jqXHR ) {

response( data[ 1 ], {

type: jqXHR.getResponseHeader( 'X-OpenSearch-Type' ),

query: query

} );

} );

}

};

Where 3010 is your namespace ID. Use "|" to separate multiple ID's.

Reply to "Namespace results in search suggestions."