Sphinx config error

Post Reply
alendelon
Posts: 9
Joined: Mon Jun 04, 2018 12:42 pm

Sphinx config error

Post by alendelon »

Сфинкс ругается на конфиг. Конфиг взял из Rotation -> Setting -> Sphinx Search -> Sphinx config (example)

В чем может быть проблема?

Code: Select all

indexer --config /etc/sphinx/bigbase.conf --all

Sphinx 2.2.11-id64-release (95ae9a6)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/etc/sphinx/bigbase.conf'...
ERROR: section contents: expected token, got '(' in /etc/sphinx/bigbase.conf line 25 col 2.
FATAL: failed to parse config file '/etc/sphinx/bigbase.conf'
Конфиг:

Code: Select all

source main_site
{
	type					= mysql

	sql_host				= localhost
	sql_user				= bigbase
	sql_pass				= N98hfsfg
	sql_db				= localhost


	sql_query_pre = SET NAMES utf8
	sql_query_pre = UPDATE rot_settings SET value = (SELECT MAX(gallery_id) FROM rot_gallery_info) WHERE name = 'sphinx_max_gallery_id'

	sql_query	= SELECT gi.gallery_id, UNIX_TIMESTAMP(gi.activation_date) as date, \
	                                                                                \
	gd.alt, gd.description, gi.duration, sponsor_id, gs.total_ctr, gi.content_type, \
	                         \
	                                                                                \
	(SELECT group_concat(tag_id) FROM rot_gal2tag g2t                               \
	WHERE g2t.gallery_id = gi.gallery_id) as tag_ids,                               \
	                                                                                \
	# TAGS START you can remove this part up to TAG END                             \
	# this part indexes tags, if you remove it - tags wont be indexed               \
	# ligther index = less memory usage and faster search                           \
	(SELECT group_concat(tag_name) FROM rot_gal2tag g2t                             \
	LEFT JOIN rot_tags as t on t.tag_id = g2t.tag_id                                \
	WHERE g2t.gallery_id = gi.gallery_id) as tags,                                  \
	                                                                \
	# TAGS END                                                                      \
	                                                                                \
	                                                                                \
	# GROUP START you can remove this part up to TAG END                            \
	# this part indexes group anmes, if you remove it - it  wont be indexed         \
	# ligther index = less memory usage and faster search                           \
	(SELECT group_concat(name) FROM rot_groups                                      \
	 WHERE rot_groups.id in (SELECT group_id FROM rot_gallery_stats1                \
	 WHERE rot_gallery_stats1.gallery_id = gi.gallery_id AND group_id != 0)         \
	 ) as group_names,                                                              \
	                                                                                \
	                                                              \
	# GROUP END                                                                     \
	                                                                                \
	                                                                                \
	(SELECT group_concat(gss.group_id) FROM rot_gallery_stats1 as gss               \
	WHERE gss.gallery_id = gi.gallery_id AND group_id != 0) as categories           \
	                                                                                \
	FROM rot_gallery_info AS gi                                                     \
	JOIN rot_gallery_data1 AS gd ON gi.gallery_id = gd.gallery_id                   \
	                                                             \
	                                                                                \
	JOIN rot_gallery_stats1 AS gs ON gs.gallery_id = gi.gallery_id                  \
	WHERE gallery_status = 'active' and gallery_type = 0                            \
	and gs.best_thumb = 'yes' and gs.group_id = 0                                   \
	AND gs.group_id NOT IN (SELECT group_id FROM rot_groups_data WHERE status != 1) 


	sql_attr_timestamp		= date
	sql_attr_uint		    = duration
	sql_attr_uint		    = sponsor_id
	sql_attr_float		    = total_ctr
	sql_attr_uint		    = content_type
    sql_attr_multi 			= uint tag_ids from field; 
    sql_attr_multi 			= uint categories from field; 

}


index main_site_index
{
	source					= main_site
	path					= /var/www/sphinx/db
	docinfo					= extern
	morphology              = stem_en
}
alendelon
Posts: 9
Joined: Mon Jun 04, 2018 12:42 pm

Re: Sphinx config error

Post by alendelon »

Запустил индексатор с конфигом отсюда:

http://smartcj.com/wiki/doku.php?id=ru: ... s[]=sphinx

Индекс создался без ошибок. Успешно запустил searchd с этим конфигом:

Code: Select all

listening on all interfaces, port=9312
listening on all interfaces, port=9306
precaching index 'main_site_index'
precached 1 indexes in 0.022 sec 
В настройках Rotation -> Setting -> Sphinx Search указал

Sphinx Host: 127.0.0.1
Sphinx Port: 9312
Sphinx Search Index: main_site_index

+ Указал в config.php

$config["sphinx_port"] = 9312;
$config["sphinx_search_index"] = 'main_site_index';

Но судя по всему поиск через sphinx не происходит.

Вбиваю на сайте кейворд в пойск, но в searchd --status :

Code: Select all

command_search: 0
- те в сфинкс запросы не идут.

Логи поиска в сфинксе включены и там тоже нет кейвордов, которые вбываю в форму поиска на сайте.

В общем связка смарт+ сфинкс у меня работать не хочет. что я не так делаю?
admin
Site Admin
Posts: 37994
Joined: Wed Sep 10, 2008 11:43 am

Re: Sphinx config error

Post by admin »

Перенос строки без экранирования (без \, любой админ сможет добавить слэш то б оно заработало :) )

идут ли запросы в сфинкс так же легко проверить - ищет ли если вы конектитесь к сфинк напрямую из шела?
Don't forget to run script update
alendelon
Posts: 9
Joined: Mon Jun 04, 2018 12:42 pm

Re: Sphinx config error

Post by alendelon »

admin wrote: Thu Jun 28, 2018 5:21 pm Перенос строки без экранирования (без \, любой админ сможет добавить слэш то б оно заработало :) )

идут ли запросы в сфинкс так же легко проверить - ищет ли если вы конектитесь к сфинк напрямую из шела?
из шела ищет

Code: Select all

# mysql -h0 -P9306
mysql> SELECT * FROM main_site_index WHERE MATCH('sex'); SHOW META;
+--------+------------+----------+------------+-----------+--------------+-------------------------------------------------------------------------------------------+------------+
| id     | date       | duration | sponsor_id | total_ctr | content_type | tag_ids                                                                                   | categories |
+--------+------------+----------+------------+-----------+--------------+-------------------------------------------------------------------------------------------+------------+
| 282342 | 1530155233 |      206 |          1 |  0.000000 |            4 | 1,112,114,125,141,166,171,178,189,224,237,333,486,638                                     | 56         |
| 284831 | 1530155533 |      362 |          1 |  0.000000 |            4 | 27,94,97,100,178,200,214,281,333,1605,1661,1862                                           | 56         |
| 290889 | 1530156317 |      357 |          1 |  0.000000 |            4 | 1,7,39,42,55,178,179,200,210,243,320,333,406,1608,2379,3858,27018,39143                   | 56         |
| 382575 | 1530167553 |      356 |          1 |  0.000000 |            4 | 100,178,200,210,241,333,406,936,3858,45265                                                | 56         |
| 234670 | 1530128715 |     1290 |          1 |  0.000000 |            4 | 29,82,125,178,200,210,251,273,290,304,361,467,1264,4591                                   | 56         |
| 237034 | 1530149778 |      180 |          1 |  0.000000 |            4 | 178,200,215,218,307,323,333,470,771,1319,1324,3546                                        | 56         |
| 237156 | 1530149780 |       30 |          1 |  0.000000 |            4 | 27,29,90,110,112,114,178,179,200,223,253,254,273,333,361,1609,6560,10674,10675            | 56         |
| 240735 | 1530150207 |       32 |          1 |  0.000000 |            4 | 7,26,29,112,114,141,178,191,200,201,237,248,301,333,655,2036,4966,12486                   | 56         |
| 241097 | 1530150262 |      356 |          1 |  0.000000 |            4 | 39,55,82,178,200,210,219,241,333,403,406,1608,2885                                        | 56         |
| 242832 | 1530150494 |       86 |          1 |  0.000000 |            4 | 35,89,112,178,200,219,221,224,298,301,323,333,376,669,1428,35447                          | 56         |
| 244399 | 1530150674 |      544 |          1 |  0.000000 |            4 | 83,106,178,333,1120                                                                       | 56         |
| 245582 | 1530150801 |      444 |          1 |  0.000000 |            4 | 7,22,132,178,200,213,323,333,1614,40465                                                   | 56         |
| 247236 | 1530150990 |      600 |          1 |  0.000000 |            4 | 6,7,89,91,178,179,200,210,218,243,249,297,301,333,376,478,747,1317,2070,2071,3546         | 56         |
| 247623 | 1530151041 |     1525 |          1 |  0.000000 |            4 | 22,24,106,139,178,218,254,333,385,2375,3546,17169                                         | 56         |
| 248411 | 1530151154 |      355 |          1 |  0.000000 |            4 | 39,82,178,200,210,241,333,403,406,1608,1749,40757                                         | 56         |
| 248499 | 1530151159 |      300 |          1 |  0.000000 |            4 | 22,24,42,55,81,82,178,200,210,241,333,3343,9547                                           | 56         |
| 250721 | 1530151436 |      405 |          1 |  0.000000 |            4 | 35,42,85,106,178,218,249,251,258,273,333,361,406,415,476,762,772,1159,1721,2389,3172,3545 | 56         |
| 251557 | 1530151520 |     1158 |          1 |  0.000000 |            4 | 38,139,142,151,178,200,216,218,333,340,341,793,1065,1614,1843,2946,3967,6639,20160        | 56         |
| 251676 | 1530151522 |      421 |          1 |  0.000000 |            4 | 42,80,106,125,162,178,249,251,265,269,273,333,387,396,3571,4556                           | 56         |
| 252827 | 1530151693 |      355 |          1 |  0.000000 |            4 | 39,55,82,178,200,210,241,333,403,406,1608,1771,3858                                       | 56         |
+--------+------------+----------+------------+-----------+--------------+-------------------------------------------------------------------------------------------+------------+
20 rows in set (0.07 sec)

+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| total         | 1000  |
| total_found   | 25277 |
| time          | 0.069 |
| keyword[0]    | sex  |
| docs[0]       | 25277 |
| hits[0]       | 31027 |
+---------------+-------+
Вопрос почему смарт через sphinx не ищет? что в настройках не так не могу понять.
admin
Site Admin
Posts: 37994
Joined: Wed Sep 10, 2008 11:43 am

Re: Sphinx config error

Post by admin »

И ничего не пишет что не может законекитться и тп ? просто 0 результатов ? точно?
Don't forget to run script update
alendelon
Posts: 9
Joined: Mon Jun 04, 2018 12:42 pm

Re: Sphinx config error

Post by alendelon »

admin wrote: Thu Jun 28, 2018 6:27 pm И ничего не пишет что не может законекитться и тп ? просто 0 результатов ? точно?
в админке ошибок не выдает никаких. поиск на сайте работает, но ищет не через сфинкс, а стандартным способом.

проверяю searchd --status выдает:
command_search: 0
connections: 1

те смарт к сфинксу не обращается хотя настройки и в админке указаны и в config.php

в cj.log есть ошибки

Code: Select all

 2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.03804612159729, 0.03804612159729) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.042181015014648, 0.042181015014648) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.038826942443848, 0.038826942443848) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.025227069854736, 0.025227069854736) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.025182962417603, 0.025182962417603) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.025789976119995, 0.025789976119995) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.03777003288269, 0.03777003288269) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.02985405921936, 0.02985405921936) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.031435966491699, 0.031435966491699) 
2018-06-28 13:55 Sphinx Error:Can not connect to Sphinx (0.032644987106323, 0.032644987106323) 
почему не может приконектится непонятно
alendelon
Posts: 9
Joined: Mon Jun 04, 2018 12:42 pm

Re: Sphinx config error

Post by alendelon »

проблема решена.

Решение:
Указать настройки:

Rotation -> Setting -> Sphinx Search

Sphinx Host: 127.0.0.1
Sphinx Port: 9306 - не 9312!
Sphinx Search Index: main_site_index
admin
Site Admin
Posts: 37994
Joined: Wed Sep 10, 2008 11:43 am

Re: Sphinx config error

Post by admin »

Да, я что то тоже не сразу заметил что почему то в шеле вы конектитесь на 9306 а в скрипте указываете 9312 ..
Don't forget to run script update
Post Reply