Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase.searchindex.php File Reference

Variables

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

Variable Documentation

◆ $wgHooks

if (!defined('MEDIAWIKI')) $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";
}
}
}
Class representing a property value snak.
Definition PropertyValueSnak.php:20
Abstract content object for articles representing Wikibase entities.
Definition EntityContent.php:38
Content object for articles representing Wikibase items.
Definition ItemContent.php:23

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