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


// 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 =
" 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"],
"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


© «Bitrix24», 2001-2024