From mediawiki.org

This page describes more advanced features of the WikiSearch extension, such as how to use property chains and how to extend WikiSearch.

Chained properties[edit]

WikiSearch provides support for creating filters with chained properties. Chained properties can be used in any filter. They can also be used as a search term property.

    "key": "Subpage.Foobar",
    "value": "+"

For instance, the above filter matches any page for which the value of the property "Subpage" is a page that contains the property "Foobar".

Special properties[edit]

There are a number of special properties defined by Semantic MediaWiki that are worth pointing out. These properties act just like regular properties, but do not appear in Special:Browse. Some of them are:

  • text_copy: (from SemanticMediaWiki documentation) this mapping is used to enable wide proximity searches on textual annotated elements. The text_copy field is a compound field for all strings to be searched when a specific property is unknown.
  • text_raw: this mapping contains unstructured, unprocessed raw text from an article.
  • attachment-title: this mapping contains the title of a file attachment.
  • attachment-content: this mapping contains the content of a file attachment.



This hook is called right before the query is sent to ElasticSearch. It has the following signature:

function onWikiSearchBeforeElasticQuery( array &$query, array &$hosts ) {}

The hook has access to and can alter the given $query. It can also add or remove hosts from the $hosts array.


This hook is called right before returning the final results to the API. It can be used to alter the $results array. This can be useful to filter any pages the user is not allowed to see or add additional data to the query result.

It has the following signature:

function onWikiSearchApplyResultTranslations( array &$results ) {}


This hook must be implemented by any WikiSearch frontend. It gets called when the #WikiSearchFrontend parser function is called. It has the following signature:

function onWikiSearchOnLoadFrontend( 
    string &$result, 
    \WikiSearch\SearchEngineConfig $config, 
    Parser $parser, 
    array $parameters 
) {}
  • string &$result: The result of the call to the parser function. This is the text that will be transcluded on the page.
  • SearchEngineConfig $config: The SearchEngineConfig object of the current page. The SearchEngineConfig object exposes the following methods:
    • getTitle(): Title: The Title associated with this SearchEngineConfig
    • getConditionProperty(): PropertyInfo: The PropertyInfo object associated with the property in the search condition (e.g. Class for Class=Foobar)
      • The PropertyInfo class exposes the following methods:
        • getPropertyID(): int: Returns the property ID
        • getPropertyType(): string: Returns the property type (e.g. txtField or wpgField)
        • getPropertyName(): string: Returns the name of the property (e.g. Class)
    • getConditionValue(): string: Returns the value in the condition (e.g. Foobar in Class=Foobar)
    • getFacetProperties(): array: Returns the facet properties in the config (facet properties are the properties that are **not** prefixed with ?). May be the name of a property (e.g. "Foobar") or a translation pair (e.g. "Foobar=Boofar")
    • getFacetPropertyIDs(): array: Returns a key-value pair list where the key is the ID of the facet property and the value the type of that property
    • getResultProperties(): array: Returns the result properties in the config as PropertyInfo objects (result properties are the properties prefixed with ?)
    • getResultPropertyIDs(): array: Returns a key-value pair list where the key is the name of the result property and the value the ID of that property
    • getSearchParameters(): array: Returns a key-value pair list of additional search parameters
  • Parser $parser: The current Parser object
  • array $parameters: The parameters passed to the #WSSearchFrontend call

Debug mode[edit]

To enable debug mode, set $wgWikiSearchEnableDebugMode to true. With debug mode enabled, the raw ElasticSearch query will be returned with each API request.