Jump to content

Extension:WikiSearch

From mediawiki.org
MediaWiki extensions manual
WikiSearch
Release status: stable
Implementation API , Parser function , Search
Description Faceted search for MediaWiki
Author(s) Xxmarijnwtalk (Wikibase Solutions) and others
Latest version 8.0.1 (2024-07-25)
MediaWiki 1.35+
PHP 7.4+
Database changes Yes
Composer open-csp/wiki-search
Tables search_facets
search_parameters
search_properties
License GNU General Public License 2.0 or later
Download
  • $wgWikiSearchElasticStoreIndex
  • $wgWikiSearchDefaultResultLimit
  • $wgWikiSearchHighlightFragmentSize
  • $wgWikiSearchHighlightNumberOfFragments
  • $wgWikiSearchElasticSearchHosts
  • $wgWikiSearchAPIRequiredRights
  • $wgWikiSearchSearchFieldOverride
  • $wgWikiSearchMaxChainedQuerySize
  • $wgWikiSearchEnableDebugMode
  • wikisearch-execute-api
  • wikisearch-edit-data-standard

The WikiSearch (previously WSSearch) extension implements a faceted search API for Semantic MediaWiki using ElasticSearch.

Usage

[edit]
  • See /api on how to use the WikiSearch API.
  • See /usage on how to use the #WikiSearchConfig parser function.
  • See /advanced on how to extend WikiSearch and how to use more advanced features such as property chains.
  • When using WikiSearchFront, one does not need to know the details of the API. To set up a search engine, use the parser functions #WikiSearchConfig and #WikiSearchFrontend on a page. WikiSearchFront is the de facto standard frontend extension for WikiSearch.

The #WikiSearchConfig parser function is used to set several configuration variables that cannot be passed to the API for security reasons. It sets the search conditions for that page and the list of facet properties. The base query parameter can be used to limit the set of pages that are included in the search.

{{#WikiSearchConfig:
  |base query=<optional: SMW query>
  |<facet property>
}}

The facet property values should correspond to existing Semantic MediaWiki properties on your wiki. For instance,

{{#WikiSearchConfig:
  |base query=[[Class::Documentation]]
  |Version
  |Tag
  |Space
}}
Only one call to #WikiSearchConfig is allowed per page. Multiple calls will result in unexpected behavior.

Configuration

[edit]

This extension provides the following optional configuration variables:

Flag Default Description
$wgWikiSearchElasticStoreIndex "smw-data-" . strtolower( wfWikiID() )) Sets the name of the ElasticStore index to use.
$wgWikiSearchDefaultResultLimit 10 Sets the number of results to return when no explicit limit is given.
$wgWikiSearchHighlightFragmentSize 250 Sets the maximum number of characters in the highlight fragment.
$wgWikiSearchHighlightNumberOfFragments 1 Sets the maximum number of highlight fragments to return per result.
$wgWikiSearchElasticSearchHosts ["localhost:9200"] Sets the list of ElasticSearch hosts to use.
$wgWikiSearchAPIRequiredRights ["read", "wssearch-execute-api"] Sets the list of rights required to query the WikiSearch API.
$wgWikiSearchSearchFieldOverride Sets the search page to redirect to when using Special:Search. The user is redirected to the specified wiki article with the query parameter search_query specified through the search page if it is available. Does not change the behaviour of the search snippets shown when using the inline search field.
$wgWikiSearchMaxChainedQuerySize 1000 Sets the maximum number of results to retrieve for a chained property query. Setting this to an extreme value may cause ElasticSearch to run out of memory when performing a large chained query.
$wgWikiSearchEnableDebugMode false Enables debug mode.

Installation

[edit]
It is recommended to use this extension in combination with WikiSearchFront.
This extension requires the Semantic MediaWiki extension with the ElasticSearch back-end.
  • Download and place the file(s) in a directory called WikiSearch in your extensions/ folder.
  • Only when installing from Git, run Composer to install PHP dependencies, by issuing composer install --no-dev in the extension directory. (See task T173141 for potential complications.)
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'WikiSearch' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

See also

[edit]