Search
Site search can work in one of four ways. It is chosen for each site separately.
Which one to pick#
bitrix: built-in. Works right away, no separate program is needed.mysql: search by the database itself. No separate program is needed either.sphinx: a separate program. Works on a server with 2 GB of memory.opensearch: a separate search server. Takes about 800 MB of memory, so it needs a server with 4 GB or more.
All four find words in different forms: a query for «договор» (contract) also finds «договоры» (contracts).
What Sphinx and OpenSearch can do#
LuckyBX installs its own settings for them. With these settings they find:
- part of a word: «холодил» for «холодильник» (fridge), «мешалка» for «бетономешалка» (concrete mixer);
- article numbers however they are written: GA-B509 and gab509, 5W-40 and 5w40, 205/55 R16 and 205/55R16, 160x200 with a Latin or a Cyrillic x;
- a piece of an article number: «b509» finds GA-B509CLWL;
- words with «е» instead of «ё»;
- brands written in Russian: «айфон», «самсунг», «макита»;
- products for the query «купить холодильник» (buy a fridge): the word «купить» is skipped;
- what was typed in the wrong keyboard layout: «cnjk» instead of «стол», «ки37» instead of rb37.
Sphinx also finds forms with a different root: the word «человек» (person) finds «люди» (people). OpenSearch also shows items where only some of the query words were found, but ranks them lower.
Bitrix can fix the keyboard layout itself, but it sometimes spoils article numbers when doing so: it turns rb37 into ки37. Sphinx and OpenSearch understand such queries anyway.
Your own synonyms and skipped words#
They are in two files shared by all sites on the server:
/etc/luckybx/search-synonyms.txt
/etc/luckybx/search-stopwords.txtIn the first one, on the left is what people search for, on the right is what is written on the site:
айфон, афон => iphoneForms of a Russian word (айфона, айфону) are added automatically. The second file has words the search skips, one per line. LuckyBX updates do not change these files.
After editing, rebuild the index, otherwise the changes do not take effect:
luckybx site search shop.example.com reindexSwitch#
luckybx site search shop.example.com mysqlThe search index is rebuilt. While it is being built, the site does not find everything. On a small site it takes seconds, on a big one it can take hours. The work runs in the background, the SSH window can be closed.
See what is used now#
luckybx site search shop.example.comThe command shows which search is chosen, how many entries are in the index, whether a rebuild is running and whether text is read from documents.
Sphinx#
Sphinx 3 is downloaded from sphinxsearch.com when it is turned on and is distributed on the terms of Sphinx Technologies, it is not part of LuckyBX.
First turn it on for the server, then for the site:
luckybx comp sphinx on
luckybx site search shop.example.com sphinxBitrix works with Sphinx by itself, no extra modules are needed. The program is reachable only from the server itself, each site has its own index. With 50 thousand entries Sphinx took about 190 MB of memory and 210 MB on disk, a normal query ran in 13 thousandths of a second, a search by part of a word in 50.
While Sphinx is not running, Bitrix cannot save any item that goes into search. So after a crash the server brings Sphinx back up by itself in a couple of seconds. If that fails, a minute later all sites with Sphinx switch to the built-in search, and you get a notification. For the same reason do not stop Sphinx by hand, turn it off like this:
luckybx comp sphinx offThe sites then switch to the built-in search first.
A full index rebuild goes into a new table, and the old one is deleted afterwards. Other sites do not notice it.
After restoring a site from a backup, rebuild the index: the backup does not have it.
OpenSearch#
First turn it on for the server, then for the site:
luckybx comp search on
luckybx site search shop.example.com opensearchOpenSearch is reachable only from the server itself. Each site has its own user and does not see other sites' data. If OpenSearch is turned off for the server, the sites switch to the built-in search by themselves first.
The LuckyBX settings are stored in OpenSearch itself, Bitrix files are not changed. If Bitrix updates its part, luckybx check asks you to rebuild the index.
If a site moved to OpenSearch before these settings appeared, rebuild the index too.
New items get into search not at once but in about a minute: they are written by the Bitrix background queue. On the other hand, if OpenSearch is down, items are still saved and appear in search when it comes back. The site search itself shows an error during that time. The server brings a crashed OpenSearch back up by itself, usually within a minute.
If the site was on Sphinx or Manticore#
When moved or cloned, a site with Sphinx switches to the built-in search. Later it can be put back on Sphinx as described above.
LuckyBX has no Manticore: Bitrix does not recognize it, and the search module settings are not saved in the admin area.
If search does not find something#
Rebuild the index:
luckybx site search shop.example.com reindexOr add only what has changed, which is faster:
luckybx site search shop.example.com reindex quickProgress is written to the site's logs/search.log.
Search in documents#
For search inside Drive files the catdoc (doc, xls, ppt) and pdftotext (pdf) programs are installed. Bitrix reads docx and xlsx text by itself.