Manual:Hooks/SearchDataForIndex2

From Linux Web Expert

Revision as of 21:55, 6 December 2023 by imported>SamanthaNguyen (style, types)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SearchDataForIndex2
<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 onSearchDataForIndex2( 
	array &$fields,
	ContentHandler $handler,
	WikiPage $page,
	ParserOutput $output,
	SearchEngine $engine,
	MediaWiki\Revision\RevisionRecord $revision
 ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"SearchDataForIndex2": "MediaWiki\\Extension\\MyExtension\\Hooks::onSearchDataForIndex2"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> content/ContentHandler.php
<translate> Interface:</translate> SearchDataForIndex2Hook.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:SearchDataForIndex2 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
  • 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.