Manual:Hooks/SearchDataForIndex

From Linux Web Expert

SearchDataForIndex
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Allows to provide custom content fields when indexing a document.
<translate> Define function:</translate>
public static function onSearchDataForIndex( array &$fields, ContentHandler $handler, WikiPage $page, ParserOutput $output, SearchEngine $engine ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"SearchDataForIndex": "MediaWiki\\Extension\\MyExtension\\Hooks::onSearchDataForIndex"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> SearchEngine.php
<translate> Interface:</translate> SearchDataForIndexHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:SearchDataForIndex extensions</tvar>.</translate>


Details

  • array &$fields: Array of name => value pairs for fields
  • ContentHandler $handler: ContentHandler for the content being indexed
  • WikiPage $page: WikiPage that is being indexed
  • ParserOutput $output: ParserOutput that is produced from the page
  • SearchEngine $engine: SearchEngine for which the indexing is intended

Add data to search document. Allows an extension to add any data to the field map used to index the document.