Documentation

OnSearchGetFileContent

mixed
handler function( string absolute_path,
string SEARCH_SESS_ID
);

"OnSearchGetFileContent" event is called during the data re-indexing of the CSearch::ReIndexFile main module.

Parameters

Parameter Description
absolute_path Absolute path to the indexed file.
SEARCH_SESS_IDID of the current indexing session. Can be used in the event handler to add additional content to the search index via the CSearch::Index method.

Returned value

Handler function can return an array, describing the file content. The array must have the following structure:

  • TITLE - title (required field);
  • CONTENT - document content;
  • PROPERTIES - array of document properties (required). If there are no such properties, an empty array must be passed. Content of this array element with the name, specified in module settings as "Page property code, where tags are stored" will be included into tags;

Or it can return false, if it cannot identify the file that must be processed.

See Also

  • CSearch::ReIndexFile
  • Examples of handler function:

    <?
    //init.php

    // index the compressed gzip files.
    // register the "OnSearchGetFileContent" event handler of the "search" module
    AddEventHandler("search", "OnSearchGetFileContent", array("CMyClass", "OnSearchGetFileContent_gzip"));

    class CMyClass
    {
    function OnSearchGetFileContent_gzip($absolute_path)
    {

    if(file_exists($absolute_path) && is_file($absolute_path) && substr($absolute_path, -3) == ".gz")
    {
    return array(
    "TITLE" => basename($absolute_path),
    "CONTENT" => implode("\n", gzfile($absolute_path)),
    "PROPERTIES" => array(),
    );
    }
    else
    return false;
    }
    }

    ?>


    © «Bitrix24», 2001-2022
    Up