Manual:Hooks/SearchDataForIndex2

SearchDataForIndex2
Available from version 1.40.0
Allows to provide custom content fields when indexing a document.
Define function:
public static function onSearchDataForIndex2( 
	array &$fields,
	ContentHandler $handler,
	WikiPage $page,
	ParserOutput $output,
	SearchEngine $engine,
	MediaWiki\Revision\RevisionRecord $revision
 ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"SearchDataForIndex2": "MediaWiki\\Extension\\MyExtension\\Hooks::onSearchDataForIndex2"
	}
}
Called from: File(s): content/ContentHandler.php
Interface: SearchDataForIndex2Hook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:SearchDataForIndex2 extensions.


Details

edit
  • 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
  • RevisionRecord $revisionRecord: The revision that is being indexed

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