Wikibase
MediaWiki Wikibase extension
Wikibase.searchindex.php File Reference

Variables

if(!defined( 'MEDIAWIKI')) global $wgHooks
 Example showing how the search index behavior for Wikibase entities can be controlled using the WikibaseTextForSearchIndex hook. More...
 

Variable Documentation

◆ $wgHooks

$wgHooks[ 'WikibaseTextForSearchIndex'][]
Initial value:
= function( EntityContent $entityContent, &$text ) {
if ( !( $entityContent instanceof ItemContent ) ) {
return;
}
$statements = $entityContent->getItem()->getStatements();
foreach ( $statements as $statement ) {
$snak = $statement->getMainSnak();
if ( !( $snak instanceof PropertyValueSnak ) ) {
continue;
}
$value = $snak->getDataValue();
if ( $value instanceof StringValue ) {
$text .= $value->getValue() . "\n";
} elseif ( $value instanceof MonolingualTextValue ) {
$text .= $value->getText() . "\n";
}
}
}

Example showing how the search index behavior for Wikibase entities can be controlled using the WikibaseTextForSearchIndex hook.

If this config file is included, the search index will include all string and text values present in the main snak of any statement associated with an item.

Author
Daniel Kinzler
Wikibase\Repo\Content\ItemContent
Content object for articles representing Wikibase items.
Definition: ItemContent.php:24
Wikibase\Repo\Content\EntityContent
Abstract content object for articles representing Wikibase entities.
Definition: EntityContent.php:50