M
M
monyavitevna2017-04-18 10:48:17
CMS
monyavitevna, 2017-04-18 10:48:17

How to setup sphinx search?

Setting up sphinx search in Bitrix on centOS.
The search works on the site, it is necessary to implement the output of such queries tshlu - nike, nike - nike, etc.
Sphinx.conf file
#!/usr/bin/php
# Ansible managed
# Minimal Sphinx configuration for Bitrix
#
# Include site search db
<?php
$includeConfig = "\n\n";
$confDir = "/etc/sphinx/bx/search_index";
if(is_dir($confDir))
{
if($dh = opendir($confDir))
{
while(($file = readdir($dh)) !== false)
{
if($file == "." || $file == "..")
continue;
$includeConfig .= file_get_contents($confDir.'/'.$file)."\n\n";
}
}
echo $includeConfig;
?>
searchd
{
listen = 9312
listen = 9306:mysql41
log = /var/log/sphinx/searchd.log
query_log = /var/log/sphinx/query.log
pid_file = /var/run/sphinx/searchd.pid
binlog_path = /var/lib/sphinx
read_timeout = 5
max_children = 30
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_max_log_size = 512M
# 2 - flush every transaction, sync every second. Good performance, and every committed transaction is guaranteed to be saved in case of daemon crash.
# 1 - flush and sync every transaction. Worst performance, but every committed transaction data is guaranteed to be saved
binlog_flush = 2
rt_flush_period = 3600
}
indexer
{
lemmatizer_cache = 128M
}
common
{
lemmatizer_base = /usr/share/sphinx/dicts
}
default.conf file
# Ansible managed
# IndexName: default
# SiteName: default
# DBName: sitemanager0
index default
{
# Main settings
type = rt
path = /var/lib/sphinx/default/index
wordforms = /var/lib/sphinx/data/wordforms.txt
docinfo = inline
# Choose appropriate type of morphology to use
#morphology = lemmatize_ru_all, lemmatize_en_all, lemmatize_de_all, stem_enru
morphology = stem_enru, soundex
# These settings are used by bitrix:search.title component
dict = keywords
prefix_fields = title
infix_fields =
min_prefix_len = 2
enable_star = 1
# All fields must be defined exactly as followed
rt_field = title
rt_field = body
rt_attr_uint = module_id
rt_attr_string = module
rt_attr_uint = item_id
rt_attr_string = item
rt_attr_uint = param1_id
rt_attr_string = param1
rt_attr_uint = param2_id
rt_attr_string = param2
rt_attr_timestamp = date_change
rt_attr_timestamp = date_to
rt_attr_timestamp = date_from
rt_attr_uint = custom_rank
rt_attr_multi = tags
rt_attr_multi = right
rt_attr_multi = site
rt_attr_multi = param
# Depends on settings of your site
# For UTFform use utf-8 else sdcs charset_type }
= utfxt file nike > nike tshlu > nike The wordforms.txt file was created by ourselves, the data folder, in which it lies, was also created by ourselves. The path to it wordforms = /var/lib/sphinx/data/wordforms.txt in the default.conf file was also written by ourselves.
The search was restarted and the site was re-indexed. But the search queries specified in the wordforms.txt file do not work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2017-04-18
@dimonchik2013

sphinxsearch.com/forum/view.html?id=10090

P
Puma Thailand, 2017-04-20
@opium

obviously the problem is in the file encoding or you have a win1251 site

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question