Manual:Enabling autocomplete in search box

From MediaWiki.org
Jump to: navigation, search

Autocomplete or Search suggestions is a feature that displays a drop-down list of suggestions below the search box while text is being typed. On the MediaWiki platform, this feature is provided by making queries to the Opensearch API.

The built-in autocomplete feature[edit]

Example of a autocomplete

MediaWiki version 1.20+:

Enabled by default. Can be disabled the same as in 1.19. $wgEnableMWSuggest has been removed.

MediaWiki version 1.13 to 1.19:

$wgUseAjax = true;
$wgEnableMWSuggest = true;

$wgUseAjax: is set true by default.
$wgEnableMWSuggest: If you are using any version above 1.19 and also using Vector as your skin, you can also set $wgVectorUseSimpleSearch = true; instead of $wgEnableMWSuggest = true;.

To disable the autocomplete feature either disable all of $wgUseAjax, or disable only the search suggestions by hiding preference disablesuggest and setting the default to true.

MediaWiki version 1.8 to 1.12:

$wgUseAjax = true;
$wgAjaxSearch = true;

MediaWiki versions 1.6 and 1.7:

$wgUseAjax = true;

See also[edit]

  • TitleKey (used by Wikipedia): Makes the prefix search backend case-insensitive (which affects Opensearch API and search suggestions).
  • Comparison matrix of search engines
    • Lucene-search: A search engine back-end for large MediaWiki websites which allows for distributed search and indexing, accentless search, stemmers for 12+ languages, link analysis for ranking, and namespace-prefixed queries. It is the search engine used by Wikimedia wikis.
      Lucene-search requires a front-end extension to fetch the results from the search engine: MWSearch (MediaWiki 1.13+) or LuceneSearch (MediaWiki 1.12 and before)
    • SphinxSearch: Smaller sites might want to consider using this instead of Lucene-search. It uses the Sphinx Search Engine as the back-end. As-you-type suggestions are available in version 0.8.2 (svn r9671) and above (This will only work in MediaWiki 1.18+)
  • Manual:Enabling autocomplete in a form: for developers, a tutorial on how to add autocomplete to any form.