Answer the question
In order to leave comments, you need to log in
How to search by strict comparison in Bitrix?
Hello!
How to implement a search in Bitrix without taking into account morphology, by strict comparison, without searching for a part of a word.
That is, if you enter "12" in the search, only "12" was found, and not "1213" or "2112".
Answer the question
In order to leave comments, you need to log in
It turned out that the search is carried out not only through the titles, but also through the description. Turning off the search by description and announcement - everything worked.
To do this, I added the code to the Init.php file
AddEventHandler("search", "BeforeIndex", "BeforeIndexHandler");
function BeforeIndexHandler($arFields) {
$arrIblock = array(айди инфоблока);
$arDelFields = array("DETAIL_TEXT", "PREVIEW_TEXT") ;
if (CModule::IncludeModule('iblock') && $arFields["MODULE_ID"] == 'iblock' && in_array($arFields["PARAM2"], $arrIblock) && intval($arFields["ITEM_ID"]) > 0){
$dbElement = CIblockElement::GetByID($arFields["ITEM_ID"]) ;
if ($arElement = $dbElement->Fetch()){
foreach ($arDelFields as $value){
if (isset ($arElement[$value]) && strlen($arElement[$value]) > 0){
$arFields["BODY"] = str_replace (CSearch::KillTags($arElement[$value]) , "", CSearch::KillTags($arFields["BODY"]) );
}
}
}
return $arFields;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question