Bitrix Site Manager

CSearch::ReindexModule

void
ReindexModule(
 string MODULE_ID [,
 bool bFull]
);

The method re-indexes the information on the specified module. The module can only be re-indexed if it had previously registered a handler of the OnReindex event of the Search module.

Parameters

ParameterDescription
MODULE_ID The ID of the module whose index is to be recreated.
bFull Specifies to perform a full re-index, all older index files deleted. Optional, false by default.

Example


<?
// register the "OnReindex" handler
RegisterModuleDependences("search", "OnReindex", "my_module", "CMyModule", "OnReindex");

// implement handler in CMyModule
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;
}

// Force the module reindexing
CSearch::ReIndexModule("my_module");

?>