- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/search/result/provider/indexsupportedprovider.php
- Класс: Bitrix\Crm\Search\Result\Provider\IndexSupportedProvider
- Вызов: IndexSupportedProvider::getSearchResult
public function getSearchResult(string $searchQuery): Result
{
$result = new Result();
$searchQuery = trim($searchQuery);
if ($searchQuery === '')
{
return $result;
}
if ($this->useDenominationSearch)
{
return $this->searchByDenomination($searchQuery);
}
$preparedSearchQuery = $this->prepareSearchQuery($searchQuery);
$priority = 0;
// search in short index
$limit = $this->getRemainingLimit($result);
if ($this->isShortIndexSupported() && $limit > 0)
{
$ids = $this->searchInShortIndex($preparedSearchQuery, $limit);
if (!empty($ids))
{
$result->addIdsByPriority($priority, $ids);
$priority++;
}
}
// search in full index
$limit = $this->getRemainingLimit($result);
if ($this->isFullIndexSupported() && $limit > 0)
{
$ids = $this->searchInFullIndex($preparedSearchQuery, $limit, $result->getIds());
if (!empty($ids))
{
$result->addIdsByPriority($priority++, $ids);
}
// add extra search results for raw numbers (not interpreted as phone):
$limit = $this->getRemainingLimit($result);
if (
Content::isIntegerToken($searchQuery)
&& $searchQuery !== $preparedSearchQuery
&& Content::canUseFulltextSearch($searchQuery, Content::TYPE_STRING)
&& $limit > 0
)
{
$ids = $this->searchInFullIndex($searchQuery, $limit, $result->getIds());
if (!empty($ids))
{
$result->addIdsByPriority($priority++, $ids);
}
}
}
// search in requisites fields
$limit = $this->getRemainingLimit($result);
if (
$this->areRequisitesSupported()
&& Content::isIntegerToken($searchQuery) // only search in requisite fields by numbers supported
&& $limit > 0
)
{
$ids = $this->searchInRequisites($searchQuery, $limit, $result->getIds());
if (!empty($ids))
{
$result->addIdsByPriority($priority++, $ids);
}
}
return $result;
}