Advertisement
Guest User

sphinx_new_config

a guest
Jul 7th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.63 KB | None | 0 0
  1. #
  2. # Minimal Sphinx configuration for Bitrix
  3. #
  4.  
  5. index bitrix
  6. {
  7. #main settings
  8. type = rt
  9. path = /var/lib/sphinxsearch/data/bitrix
  10. docinfo = inline
  11. #ondisc_attrs=1
  12. #choose appropriate type of morphology to use
  13. #morphology = lemmatize_ru_all, lemmatize_en_all, lemmatize_de_all, stem_enru
  14. morphology = stem_enru, soundex
  15. #these settings are used by bitrix:search.title component
  16. dict = keywords
  17. prefix_fields = title
  18. infix_fields=
  19. min_prefix_len = 2
  20. enable_star = 1
  21. #all fields must be defined exactly as followed
  22. rt_field = title
  23. rt_field = body
  24. rt_attr_uint = module_id
  25. rt_attr_string = module
  26. rt_attr_uint = item_id
  27. rt_attr_string = item
  28. rt_attr_uint = param1_id
  29. rt_attr_string = param1
  30. rt_attr_uint = param2_id
  31. rt_attr_string = param2
  32. rt_attr_timestamp = date_change
  33. rt_attr_timestamp = date_to
  34. rt_attr_timestamp = date_from
  35. rt_attr_uint = custom_rank
  36. rt_attr_multi = tags
  37. rt_attr_multi = right
  38. rt_attr_multi = site
  39. rt_attr_multi = param
  40. #depends on settings of your site
  41. # uncomment for single byte character set
  42. charset_type = sbcs
  43. # uncomment for UTF character set
  44. #charset_type = utf-8
  45. }
  46.  
  47. source bitrix2
  48. {
  49. type = mysql
  50. sql_host = localhost
  51. sql_user = avselectro
  52. sql_pass = MDJlNjBjZT
  53. sql_db = avselectro
  54. sql_port = 3306
  55.  
  56. sql_query_pre = SET NAMES utf8
  57. # sql_query_pre = SET group_concat_max_len = 4096
  58. # sql_query_pre = TRUNCATE TABLE `tmp_features`
  59. # sql_query_pre = \
  60. # INSERT INTO `tmp_features` (`raec_id`, `features`)\
  61. # SELECT `PRODUCTID`,\
  62. # CONCAT('{', GROUP_CONCAT(CONCAT('"', `product_values`.`FEATUREID`, '":', `product_values`.`VAL`, '')), '}') AS `features`\
  63. # FROM (\
  64. # SELECT `PRODUCTID`, `FEATUREID`, CONCAT('[', GROUP_CONCAT(CONCAT('"', IFNULL(`VALUE`, `IBLOCK_ELEMENT_ID`), '"')), ']') AS `VAL`\
  65. # FROM `tmp_product_feature_value_map`\
  66. # GROUP BY `PRODUCTID`, `FEATUREID`\
  67. # ) AS `product_values`\
  68. # GROUP BY `PRODUCTID`;
  69.  
  70. sql_query = \
  71. SELECT `product`.`ID` AS `id`,\
  72. `product`.`XML_ID` AS `xml_id`,\
  73. `product`.`SHOW_COUNTER` AS `rating`,\
  74. `brands`.`ID` AS `brand_id`,\
  75. `prop`.`PROPERTY_20` AS `article`,\
  76. `prop`.`PROPERTY_51`>0 AS `is_sale`,\
  77. `prop`.`PROPERTY_52`>0 AS `is_new`,\
  78. `prop`.`PROPERTY_67`>0 AS `is_special`,\
  79. `brands`.`NAME` AS `brand`,\
  80. `product`.`NAME` AS `title`,\
  81. `product`.`DETAIL_TEXT` AS `text`,\
  82. `store`.`AMOUNT`>0 AS `remains`,\
  83. `price`.`PRICE` AS `price`,\
  84. `etimclasses`.`CODE` AS `etimclass_id`,\
  85. `tmp_features`.`features` AS `features`,\
  86. `tmp_features`.`values` AS `values`\
  87. FROM `b_iblock_element` AS `product`\
  88. LEFT JOIN `b_catalog_store_product` AS `store` ON `store`.`STORE_ID` = 32 AND `store`.`PRODUCT_ID` = `product`.`ID`\
  89. LEFT JOIN `b_catalog_price` AS `price` ON `price`.`CATALOG_GROUP_ID` = 6 AND `price`.`PRODUCT_ID` = `product`.`ID`\
  90. LEFT JOIN `b_iblock_element_prop_s6` AS `prop` ON `prop`.`IBLOCK_ELEMENT_ID` = `product`.`ID`\
  91. LEFT JOIN `b_iblock_element` AS `etimclasses` ON `etimclasses`.`IBLOCK_ID` = 4 AND `etimclasses`.`ACTIVE` = 'Y' AND `prop`.`PROPERTY_17` = `etimclasses`.`ID`\
  92. LEFT JOIN `b_iblock_element` AS `brands` ON `brands`.`IBLOCK_ID` = 7 AND `brands`.`ACTIVE` = 'Y' AND `prop`.`PROPERTY_19` = `brands`.`ID`\
  93. LEFT JOIN `tmp_features` ON `tmp_features`.`raec_id` = `prop`.`PROPERTY_27`\
  94. WHERE `product`.`IBLOCK_ID` = 6;
  95.  
  96. sql_attr_multi = uint section_id from query; SELECT `IBLOCK_ELEMENT_ID` AS `id`, `IBLOCK_SECTION_ID` AS `section_id` FROM `b_iblock_section_element`
  97. sql_attr_uint = brand_id
  98. sql_attr_uint = xml_id
  99. sql_attr_uint = rating
  100. sql_attr_bool = is_sale
  101. sql_attr_bool = is_new
  102. sql_attr_bool = is_special
  103. sql_attr_bool = remains
  104. sql_attr_float = price
  105. sql_attr_string = etimclass_id
  106. sql_attr_string = title
  107. sql_attr_json = features
  108. }
  109.  
  110. index bitrix2
  111. {
  112. type = plain
  113. source = bitrix2
  114. path = /var/www/sphinx/data/bitrix2
  115. mlock = 0
  116. morphology = stem_en, stem_ru, soundex
  117. min_word_len = 2
  118. html_strip = 1
  119. preopen = 1
  120. }
  121.  
  122. source catalog
  123. {
  124. # Параметры подключения к БД
  125. type = mysql
  126. sql_host = localhost
  127. sql_user = avselectro
  128. sql_pass = MDJlNjBjZT
  129. sql_db = avselectro
  130. sql_port = 3306
  131.  
  132. # Установим кодировку для работы с БД
  133. sql_query_pre = SET NAMES utf8
  134. sql_query_pre = SET CHARACTER SET utf8
  135.  
  136. # Запрос выборки данных для индексации
  137. #sql_query = SELECT ID as post_id, post_title, post_content FROM wp_posts WHERE post_type = 'post'
  138. #sql_query = SELECT IBLOCK_ELEMENT_ID, PROPERTY_35 FROM b_iblock_element_prop_s6
  139. sql_query = SELECT ID, NAME, PROPERTY_35, PROPERTY_81 FROM b_iblock_element LEFT OUTER JOIN b_iblock_element_prop_s6 ON ID = IBLOCK_ELEMENT_ID WHERE IBLOCK_ID=6
  140.  
  141. #sql_query = SELECT ID, NAME FROM b_iblock_element
  142.  
  143. # Запрос доп. информации для вывода результата (используется утилитой "search")
  144. #sql_query_info = SELECT * FROM b_iblock_elemnt_prop_s6 WHERE IBLOCK_ELEMENT_ID = $id
  145.  
  146. # Время простоя (sleep) перед посылкой запросов серверу (предназначен для разгрузки сервера БД)
  147. # Если установите "= 1000", то засыпание будет длится 1 секунду
  148. sql_ranged_throttle = 0
  149. }
  150.  
  151. index catalog
  152. {
  153. # Использовать соответствующий source-блок настроек при индексации
  154. source = catalog
  155.  
  156. # Путь до файлов индекса
  157. path = /var/www/sphinx/data/catalog
  158.  
  159. # Использование английского и русского стемминга
  160. morphology = stem_enru
  161.  
  162. # Минимальная длина индексируемого слова
  163. min_word_len = 2
  164.  
  165. # Установка используемой кодировки
  166. #charset_type = utf-8
  167. }
  168.  
  169. source ETIM_catalog
  170. {
  171. # Параметры подключения к БД
  172. type = mysql
  173. sql_host = localhost
  174. sql_user = avselectro
  175. sql_pass = MDJlNjBjZT
  176. sql_db = avselectro
  177. sql_port = 3306
  178.  
  179. # Установим кодировку для работы с БД
  180. sql_query_pre = SET NAMES utf8
  181. sql_query_pre = SET CHARACTER SET utf8
  182.  
  183. # Запрос выборки данных для индексации
  184. # sql_query = SELECT b_iblock_element.ID, b_iblock_element.NAME, b_iblock_element.CODE,b_iblock_element_prop_s4.PROPERTY_6, b_iblock_element_prop_m4.VALUE FROM b_iblock_element LEFT OUTER JOIN b_iblock_element_prop_s4 ON b_iblock_element.ID = b_iblock_element_prop_s4.IBLOCK_ELEMENT_ID LEFT OUTER JOIN b_iblock_element_prop_m4 ON b_iblock_element.ID = b_iblock_element_prop_m4.IBLOCK_ELEMENT_ID WHERE IBLOCK_ID=4
  185.  
  186. sql_query = SELECT b_iblock_element_prop_s6.IBLOCK_ELEMENT_ID, b_iblock_element.NAME, b_iblock_element.CODE, b_iblock_element_prop_s4.PROPERTY_6, b_iblock_element_prop_m4.VALUE FROM b_iblock_element LEFT OUTER JOIN b_iblock_element_prop_s4 ON b_iblock_element.ID = b_iblock_element_prop_s4.IBLOCK_ELEMENT_ID LEFT OUTER JOIN b_iblock_element_prop_m4 ON b_iblock_element.ID = b_iblock_element_prop_m4.IBLOCK_ELEMENT_ID LEFT OUTER JOIN b_iblock_element_prop_s6 ON b_iblock_element.ID = b_iblock_element_prop_s6.PROPERTY_17 WHERE IBLOCK_ID=4
  187.  
  188.  
  189. # Время простоя (sleep) перед посылкой запросов серверу (предназначен для разгрузки сервера БД)
  190. # Если установите "= 1000", то засыпание будет длится 1 секунду
  191. sql_ranged_throttle = 0
  192. }
  193.  
  194. index ETIM_catalog
  195. {
  196. # Использовать соответствующий source-блок настроек при индексации
  197. source = ETIM_catalog
  198.  
  199. # Путь до файлов индекса
  200. path = /var/www/sphinx/data/ETIM_catalog
  201.  
  202. # Использование английского и русского стемминга
  203. morphology = stem_enru
  204.  
  205. # Минимальная длина индексируемого слова
  206. min_word_len = 2
  207.  
  208. # Установка используемой кодировки
  209. #charset_type = utf-8
  210.  
  211. #wordforms = /var/www/sphinx/dic.txt
  212. }
  213.  
  214. source CODE_catalog
  215. {
  216. # Параметры подключения к БД
  217. type = mysql
  218. sql_host = localhost
  219. sql_user = avselectro
  220. sql_pass = MDJlNjBjZT
  221. sql_db = avselectro
  222. sql_port = 3306
  223.  
  224. # Установим кодировку для работы с БД
  225. sql_query_pre = SET NAMES utf8
  226. sql_query_pre = SET CHARACTER SET utf8
  227.  
  228. # Запрос выборки данных для индексации
  229. sql_query = SELECT IBLOCK_ELEMENT_ID, PROPERTY_27, PROPERTY_20, PROPERTY_25, PROPERTY_24 FROM b_iblock_element_prop_s6
  230.  
  231. # Время простоя (sleep) перед посылкой запросов серверу (предназначен для разгрузки сервера БД)
  232. # Если установите "= 1000", то засыпание будет длится 1 секунду
  233. sql_ranged_throttle = 0
  234. }
  235.  
  236. index CODE_catalog
  237. {
  238. # Использовать соответствующий source-блок настроек при индексации
  239. source = CODE_catalog
  240.  
  241. # Путь до файлов индекса
  242. path = /var/www/sphinx/data/CODE_catalog
  243.  
  244. # Использование английского и русского стемминга
  245. morphology = stem_enru
  246.  
  247. # Минимальная длина индексируемого слова
  248. min_word_len = 2
  249.  
  250. # Установка используемой кодировки
  251. #charset_type = utf-8
  252.  
  253. #wordforms = /var/www/sphinx/dic.txt
  254. }
  255.  
  256. #############################################################################
  257. ## indexer settings
  258. #############################################################################
  259. indexer
  260. {
  261. # memory limit, in bytes, kiloytes (16384K) or megabytes (256M)
  262. # optional, default is 32M, max is 2047M, recommended is 256M to 1024M
  263. mem_limit = 256M
  264.  
  265. # maximum IO calls per second (for I/O throttling)
  266. # optional, default is 0 (unlimited)
  267. #
  268. # max_iops = 40
  269.  
  270.  
  271. # maximum IO call size, bytes (for I/O throttling)
  272. # optional, default is 0 (unlimited)
  273. #
  274. # max_iosize = 1048576
  275.  
  276.  
  277. # maximum xmlpipe2 field length, bytes
  278. # optional, default is 2M
  279. #
  280. # max_xmlpipe2_field = 4M
  281.  
  282.  
  283. # write buffer size, bytes
  284. # several (currently up to 4) buffers will be allocated
  285. # write buffers are allocated in addition to mem_limit
  286. # optional, default is 1M
  287. #
  288. # write_buffer = 1M
  289.  
  290.  
  291. # maximum file field adaptive buffer size
  292. # optional, default is 8M, minimum is 1M
  293. #
  294. # max_file_field_buffer = 32M
  295. lemmatizer_cache = 128M
  296.  
  297. }
  298.  
  299. #############################################################################
  300. ## searchd settings
  301. #############################################################################
  302. searchd
  303. {
  304. # [hostname:]port[:protocol], or /unix/socket/path to listen on
  305. # known protocols are 'sphinx' (SphinxAPI) and 'mysql41' (SphinxQL)
  306. #
  307. # multi-value, multiple listen points are allowed
  308. # optional, defaults are 9312:sphinx and 9306:mysql41, as below
  309. #
  310. # listen = 127.0.0.1
  311. # listen = 192.168.0.1:9312
  312. # listen = 9312
  313. # listen = /var/run/searchd.sock
  314. listen = 9312:sphinx
  315. listen = 9306:mysql41
  316.  
  317. # log file, searchd run info is logged here
  318. # optional, default is 'searchd.log'
  319. log = /var/log/sphinxsearch/searchd.log
  320. # query log file, all search queries are logged here
  321. # optional, default is empty (do not log queries)
  322. query_log = /var/log/sphinxsearch/query.log
  323.  
  324. # client read timeout, seconds
  325. # optional, default is 5
  326. read_timeout = 5
  327.  
  328. # request timeout, seconds
  329. # optional, default is 5 minutes
  330. client_timeout = 300
  331.  
  332. # maximum amount of children to fork (concurrent searches to run)
  333. # optional, default is 0 (unlimited)
  334. max_children = 30
  335.  
  336. # PID file, searchd process ID file name
  337. # mandatory
  338. pid_file = /var/run/sphinxsearch/searchd.pid
  339.  
  340. # max amount of matches the daemon ever keeps in RAM, per-index
  341. # WARNING, THERE'S ALSO PER-QUERY LIMIT, SEE SetLimits() API CALL
  342. # default is 1000 (just like Google)
  343. #max_matches = 1000
  344.  
  345. # seamless rotate, prevents rotate stalls if precaching huge datasets
  346. # optional, default is 1
  347. seamless_rotate = 1
  348.  
  349. # whether to forcibly preopen all indexes on startup
  350. # optional, default is 1 (preopen everything)
  351. preopen_indexes = 1
  352.  
  353. # whether to unlink .old index copies on succesful rotation.
  354. # optional, default is 1 (do unlink)
  355. unlink_old = 1
  356.  
  357. # attribute updates periodic flush timeout, seconds
  358. # updates will be automatically dumped to disk this frequently
  359. # optional, default is 0 (disable periodic flush)
  360. #
  361. # attr_flush_period = 900
  362.  
  363.  
  364. # instance-wide ondisk_dict defaults (per-index value take precedence)
  365. # optional, default is 0 (precache all dictionaries in RAM)
  366. #
  367. # ondisk_dict_default = 1
  368.  
  369.  
  370. # MVA updates pool size
  371. # shared between all instances of searchd, disables attr flushes!
  372. # optional, default size is 1M
  373. mva_updates_pool = 1M
  374.  
  375. # max allowed network packet size
  376. # limits both query packets from clients, and responses from agents
  377. # optional, default size is 8M
  378. max_packet_size = 8M
  379.  
  380. # crash log path
  381. # searchd will (try to) log crashed query to 'crash_log_path.PID' file
  382. # optional, default is empty (do not create crash logs)
  383. #
  384. # crash_log_path = /var/log/sphinxsearch/crash
  385.  
  386.  
  387. # max allowed per-query filter count
  388. # optional, default is 256
  389. max_filters = 256
  390.  
  391. # max allowed per-filter values count
  392. # optional, default is 4096
  393. max_filter_values = 4096
  394.  
  395.  
  396. # socket listen queue length
  397. # optional, default is 5
  398. #
  399. # listen_backlog = 5
  400.  
  401.  
  402. # per-keyword read buffer size
  403. # optional, default is 256K
  404. #
  405. # read_buffer = 256K
  406.  
  407. # unhinted read size (currently used when reading hits)
  408. # optional, default is 32K
  409. #
  410. # read_unhinted = 32K
  411.  
  412.  
  413. # max allowed per-batch query count (aka multi-query count)
  414. # optional, default is 32
  415. max_batch_queries = 200
  416.  
  417.  
  418. # max common subtree document cache size, per-query
  419. # optional, default is 0 (disable subtree optimization)
  420. #
  421. subtree_docs_cache = 8M
  422.  
  423.  
  424. # max common subtree hit cache size, per-query
  425. # optional, default is 0 (disable subtree optimization)
  426. #
  427. subtree_hits_cache = 16M
  428.  
  429. # multi-processing mode (MPM)
  430. # known values are none, fork, prefork, and threads
  431. # optional, default is fork
  432. #
  433. workers = threads
  434.  
  435.  
  436. # max threads to create for searching local parts of a distributed index
  437. # optional, default is 0, which means disable multi-threaded searching
  438. # should work with all MPMs (ie. does NOT require workers=threads)
  439. #
  440. # dist_threads = 4
  441.  
  442.  
  443. # binlog files path; use empty string to disable binlog
  444. # optional, default is build-time configured data directory
  445. #
  446. # binlog_path = # disable logging
  447. # binlog_path = /var/lib/sphinxsearch/data # binlog.001 etc will be created there
  448. binlog_path = /var/lib/sphinxsearch/data/
  449.  
  450.  
  451. # binlog flush/sync mode
  452. # 0 means flush and sync every second
  453. # 1 means flush and sync every transaction
  454. # 2 means flush every transaction, sync every second
  455. # optional, default is 2
  456. #
  457. binlog_flush = 2
  458.  
  459.  
  460. # binlog per-file size limit
  461. # optional, default is 128M, 0 means no limit
  462. #
  463. binlog_max_log_size = 512M
  464.  
  465.  
  466. # per-thread stack size, only affects workers=threads mode
  467. # optional, default is 64K
  468. #
  469. # thread_stack = 128K
  470.  
  471.  
  472. # per-keyword expansion limit (for dict=keywords prefix searches)
  473. # optional, default is 0 (no limit)
  474. #
  475. # expansion_limit = 1000
  476.  
  477.  
  478. # RT RAM chunks flush period
  479. # optional, default is 0 (no periodic flush)
  480. #
  481. rt_flush_period = 3600
  482.  
  483.  
  484. # query log file format
  485. # optional, known values are plain and sphinxql, default is plain
  486. #
  487. query_log_format = sphinxql
  488.  
  489. # version string returned to MySQL network protocol clients
  490. # optional, default is empty (use Sphinx version)
  491. #
  492. # mysql_version_string = 5.0.37
  493.  
  494.  
  495. # trusted plugin directory
  496. # optional, default is empty (disable UDFs)
  497. #
  498. # plugin_dir = /usr/local/sphinx/lib
  499.  
  500.  
  501. # default server-wide collation
  502. # optional, default is libc_ci
  503. #
  504. # collation_server = utf8_general_ci
  505.  
  506.  
  507. # server-wide locale for libc based collations
  508. # optional, default is C
  509. #
  510. # collation_libc_locale = ru_RU.UTF-8
  511.  
  512. # threaded server watchdog (only used in workers=threads mode)
  513. # optional, values are 0 and 1, default is 1 (watchdog on)
  514. #
  515. # watchdog = 1
  516.  
  517.  
  518. # SphinxQL compatibility mode (legacy columns and their names)
  519. # optional, default is 0 (SQL compliant syntax and result sets)
  520. #
  521. # compat_sphinxql_magics = 1
  522. }
  523.  
  524. # common settings
  525.  
  526. common
  527. {
  528. json_autoconv_numbers = 1
  529. #json_autoconv_keynames = lowercase
  530. lemmatizer_base = /etc/sphinxsearch/dicts/
  531.  
  532. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement