Documentation

ReindexModule

void
CSearch::ReindexModule( string MODULE_ID, bool bFull = false );

The method initiates re-indexing of specified module. For the module to be re-indexed, it must provide a correposnding method, which must be registered in the event system as the OnReIndex event handler for the "search" module. Static method.

This method cannot re-index the data of the "main" module, i. e. file indexing is performed not via event handlers, but directly by the search module. However, the CSearch::ReIndexAll method can be used, by passing $NS = array("MODULE_ID"=>"main") during the first step.

Note: this method uses internal transaction. If you use MySQL and InnoDB, and a transaction was opened previously, it must be closed prior to connecting the method.

Method parameters

Parameter Description
MODULE_ID Code of the module which requires re-indexing.
bFull Specifies whether full re-indexing must be performed with cleaning of the old search indexes. Optional parameter, equals false by default.

See Also

Examples of use

OnReindex.

// register the "OnReindex" event handler of the "search" module
RegisterModuleDependences("search", "OnReindex", "my_module", "CMyModule", "OnReindex");

// create OnReindex method in the CMyModule in the "my_module" module
function OnReindex()
{
global $DB;
$arResult = array();

$strSql =
"SELECT FT.ID, FT.TITLE, FT.MESSAGE, ".
" DATE_FORMAT(FT.POST_DATE, '%d.%m.%Y %H:%i:%s') as POST_DATE, FT.LID ".
"FROM b_my_table FT ";

$db_res = $DB->Query($strSql);
while ($res = $db_res->Fetch())
{
$arResult[] = array(
"ID" => $res["ID"],
"LID" => $res["LID"],
"DATE_CHANGE" => $res["POST_DATE"],
"URL" => "/my_module/index.php?ID=".$res["ID"],
"PERMISSIONS" => array(2),
"TITLE" => $res["TITLE"],
"BODY" => $res["POST_MESSAGE"]
);
}
return $arResult;
}

// call the module re-indexing
CSearch::ReIndexModule("my_module");

?>


© «Bitrix24», 2001-2024
Up