Setting up autocomplete for 1C-Bitrix search

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Search Autocomplete Setup for Bitrix CMS

Search autocomplete — completing a typed query into a full search term — differs from suggestions: suggestions show specific products or pages, autocomplete proposes query variants. In Bitrix, these concepts are often confused, and implementation depends on which functionality is actually needed.

Two Autocomplete Scenarios

Scenario 1: Autocomplete by Search Index User types "red", system suggests: "red dresses", "red sneakers", "red couch". Source — titles from b_search_content.

Scenario 2: Autocomplete by Query History System suggests popular queries from other users matching typed characters. Source — search history from b_search_user_trans (if history tracking enabled).

The standard bitrix:search.suggest component implements scenario 1. Scenario 2 requires custom development.

Enabling Search History

Settings → Search → Module Settings → Save search history — enable.

History is saved in b_search_user_trans. Fields: SITE_ID, WORD (search query), DATE_CHANGE, POPULARITY (repeat count).

Implementing Autocomplete by Popular Queries

AJAX endpoint for autocomplete by history:

// /local/ajax/search_autocomplete.php
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';

$query = trim($_GET['q']);
if (strlen($query) < 2) {
    die(json_encode([]));
}

$result = \Bitrix\Main\Application::getConnection()->query(
    "SELECT WORD, POPULARITY FROM b_search_user_trans
     WHERE SITE_ID = '" . SITE_ID . "'
     AND WORD LIKE '" . \Bitrix\Main\DB\MssqlConnection::ForSql($query) . "%'
     ORDER BY POPULARITY DESC
     LIMIT 10"
);

$suggestions = [];
while ($row = $result->fetch()) {
    $suggestions[] = $row['WORD'];
}
echo json_encode($suggestions);

Frontend — standard input with input event handler and 200–300 ms debounce.

Combining Suggestions and Autocomplete

In practice, the most convenient UX is a combined dropdown:

  • Top section: 3–5 popular queries (autocomplete)
  • Bottom section: 5–7 specific products (suggestions with images)

Implemented via two parallel AJAX requests or single endpoint returning both data types.

Caching

Autocomplete requests execute with each character input — important to cache responses. Options:

  • Bitrix cache (\Bitrix\Main\Data\Cache) with 30–60 minute TTL
  • Redis/Memcached for storing popular queries
  • Static files for top-100 popular queries (updated by agent hourly)

Implementation Timeline

Standard autocomplete setup via suggestions component — 1–2 hours. Custom autocomplete by query history with combined UI — 4–8 hours.