sphinx2.conf 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. #############################################################################
  2. ## data source definition
  3. #############################################################################
  4. source src1
  5. {
  6. type = mysql
  7. sql_host = 127.0.0.1
  8. sql_user = root
  9. sql_pass = rootpassword
  10. sql_db = stg
  11. sql_port = 3306 # optional, default is 3306
  12. sql_query_pre = SET NAMES utf8
  13. sql_query = \
  14. SELECT `nethosts`.`id`, 'ip' AS `title`, `nethosts`.`ip` as value, `users`.`login` \
  15. FROM `nethosts` RIGHT JOIN `users` ON `nethosts`.`ip` = `users`.`ip`
  16. sql_attr_string = login
  17. sql_attr_string = title
  18. sql_field_string = value
  19. sql_ranged_throttle = 0
  20. }
  21. source src2 : src1
  22. {
  23. sql_query = \
  24. SELECT `nethosts`.`id`, 'realname' AS `title`, `users`.`login`, `realname`.`realname` as value \
  25. FROM `nethosts` RIGHT JOIN `users` ON `nethosts`.`ip` = `users`.`ip` JOIN `realname` ON `realname`.`login` = `users`.`login` WHERE `realname`.`realname` <> ''
  26. sql_attr_string = login
  27. sql_attr_string = title
  28. sql_field_string = value
  29. }
  30. source src3 : src1
  31. {
  32. sql_query = \
  33. SELECT `nethosts`.`id`, 'mac' AS `title`, `nethosts`.`mac` AS `value`, `users`.`login` \
  34. FROM `nethosts` RIGHT JOIN `users` ON `nethosts`.`ip` = `users`.`ip`
  35. sql_attr_string = login
  36. sql_attr_string = title
  37. sql_field_string = value
  38. }
  39. source src4 : src1
  40. {
  41. sql_query = \
  42. SELECT `nethosts`.`id`, 'login' AS `title`, `users`.`login` AS `value`, `users`.`login` AS `login` \
  43. FROM `nethosts` RIGHT JOIN `users` ON `nethosts`.`ip` = `users`.`ip`
  44. sql_attr_string = login
  45. sql_attr_string = title
  46. sql_field_string = value
  47. }
  48. source src5 : src1
  49. {
  50. sql_query = \
  51. SELECT nethosts.id, 'address' AS `title`, `users`.`login`,concat(`cityname`, ' ', `streetname`, ' ', `buildnum`, IF(`apt`, concat('/',`apt`), '')) AS `value` \
  52. FROM `users` LEFT JOIN `nethosts` USING (`ip`) \
  53. LEFT JOIN `address` ON (`users`.`login`=`address`.`login`) \
  54. LEFT JOIN `apt` ON (`address`.`aptid`=`apt`.`id`) \
  55. LEFT JOIN `build` ON (`apt`.`buildid`=`build`.`id`) \
  56. LEFT JOIN `street` ON (`build`.`streetid`=`street`.`id`) \
  57. LEFT JOIN `city` ON (`street`.`cityid`=`city`.`id`)
  58. sql_attr_string = login
  59. sql_attr_string = title
  60. sql_field_string = value
  61. }
  62. source src6 : src1
  63. {
  64. sql_query = \
  65. SELECT `nethosts`.`id`, 'mobile' AS `title`, `users`.`login`, `phones`.`mobile` as `value` \
  66. FROM `nethosts` RIGHT JOIN `users` ON `nethosts`.`ip` = `users`.`ip` LEFT JOIN `phones` ON `users`.`login` = `phones`.`login` WHERE `phones`.`mobile` <> ''
  67. sql_attr_string = login
  68. sql_attr_string = title
  69. sql_field_string = value
  70. }
  71. source src7 : src1
  72. {
  73. sql_query = \
  74. SELECT `nethosts`.`id`, 'phone' AS `title`, `users`.`login`, `phones`.`phone` as `value` \
  75. FROM `nethosts` RIGHT JOIN `users` ON `nethosts`.`ip` = `users`.`ip` LEFT JOIN `phones` ON `users`.`login` = `phones`.`login` WHERE `phones`.`phone` <> ''
  76. sql_attr_string = login
  77. sql_attr_string = title
  78. sql_field_string = value
  79. }
  80. source src8 : src1
  81. {
  82. sql_query = \
  83. SELECT `nethosts`.`id`, 'contracts' AS `title`, `users`.`login`, `contracts`.`contract` as `value` \
  84. FROM `nethosts` RIGHT JOIN `users` ON `nethosts`.`ip` = `users`.`ip` LEFT JOIN `contracts` ON `users`.`login` = `contracts`.`login`
  85. sql_attr_string = login
  86. sql_attr_string = title
  87. sql_field_string = value
  88. }
  89. source src9 : src1
  90. {
  91. sql_query = \
  92. SELECT `nethosts`.`id`, 'paymentid' AS `title`, `users`.`login`, `op_customers`.`virtualid` as `value` \
  93. FROM `nethosts` RIGHT JOIN `users` ON `nethosts`.`ip` = `users`.`ip` LEFT JOIN `op_customers` ON `users`.`login` = `op_customers`.`realid`
  94. sql_attr_string = login
  95. sql_attr_string = title
  96. sql_field_string = value
  97. }
  98. source src10 : src1
  99. {
  100. sql_query = SELECT `nethosts`.`id`,'mac' AS `title`,CONCAT(SUBSTRING_INDEX(`nethosts`.`mac`, ':', 1),'-',SUBSTRING_INDEX(SUBSTRING_INDEX(`nethosts`.`mac`,':',2),':', -1),'-',SUBSTRING_INDEX(SUBSTRING_INDEX(`nethosts`.`mac`,':',3),':', -1),'-',SUBSTRING_INDEX(SUBSTRING_INDEX(`nethosts`.`mac`,':',4),':', -1),'-',SUBSTRING_INDEX(SUBSTRING_INDEX(`nethosts`.`mac`,':',5),':', -1),'-',SUBSTRING_INDEX(`nethosts`.`mac`, ':', -1)) as `value`, `users`.`login` FROM `nethosts` RIGHT JOIN `users` USING(`ip`)
  101. sql_attr_string = login
  102. sql_attr_string = title
  103. sql_field_string = value
  104. }
  105. source src11 : src1
  106. {
  107. sql_query = SELECT `nethosts`.`id`,'mac' AS `title`,CONCAT(SUBSTRING_INDEX(`nethosts`.`mac`, ':', 1),SUBSTRING_INDEX(SUBSTRING_INDEX(`nethosts`.`mac`,':',2),':', -1),'.',SUBSTRING_INDEX(SUBSTRING_INDEX(`nethosts`.`mac`,':',3),':', -1),SUBSTRING_INDEX(SUBSTRING_INDEX(`nethosts`.`mac`,':',4),':', -1),'.',SUBSTRING_INDEX(SUBSTRING_INDEX(`nethosts`.`mac`,':',5),':', -1),SUBSTRING_INDEX(`nethosts`.`mac`, ':', -1)) as `value`, `users`.`login` FROM `nethosts` RIGHT JOIN `users` USING(`ip`)
  108. sql_attr_string = login
  109. sql_attr_string = title
  110. sql_field_string = value
  111. }
  112. #############################################################################
  113. ## index definition
  114. #############################################################################
  115. index ip
  116. {
  117. source = src1
  118. path = /opt/sphinx/sphinxdata/ip
  119. mlock = 0
  120. morphology = none
  121. min_word_len = 1
  122. min_prefix_len = 1
  123. expand_keywords = 1
  124. html_strip = 0
  125. blend_mode = trim_both, skip_pure
  126. blend_chars = U+002B,U+002D,U+003A,U+002E,U+002C,U+0027,U+0060
  127. }
  128. index mac : ip
  129. {
  130. source = src3
  131. path = /opt/sphinx/sphinxdata/mac
  132. }
  133. index realname : ip
  134. {
  135. source = src2
  136. path = /opt/sphinx/sphinxdata/realname
  137. }
  138. index login : ip
  139. {
  140. source = src4
  141. path = /opt/sphinx/sphinxdata/login
  142. }
  143. index fulladdress : ip
  144. {
  145. source = src5
  146. path = /opt/sphinx/sphinxdata/fulladdres
  147. }
  148. index mobile : ip
  149. {
  150. source = src6
  151. path = /opt/sphinx/sphinxdata/mobile
  152. }
  153. index phone : ip
  154. {
  155. source = src7
  156. path = /opt/sphinx/sphinxdata/phone
  157. }
  158. index contract : ip
  159. {
  160. source = src8
  161. path = /opt/sphinx/sphinxdata/contract
  162. }
  163. #index paymentid : ip
  164. #{
  165. # source = src9
  166. # path = /opt/sphinx/sphinxdata/paymentid
  167. #}
  168. #index macminus : ip
  169. #{
  170. # source = src10
  171. # path = /opt/sphinx/sphinxdata/macminus
  172. #}
  173. #index macdot : ip
  174. #{
  175. # source = src11
  176. # path = /opt/sphinx/sphinxdata/macdot
  177. #}
  178. #############################################################################
  179. ## indexer settings
  180. #############################################################################
  181. indexer
  182. {
  183. mem_limit = 128M
  184. # max_iops = 40
  185. # max_iosize = 1048576
  186. # max_xmlpipe2_field = 4M
  187. # write_buffer = 1M
  188. # max_file_field_buffer = 32M
  189. # on_file_field_error = skip_document
  190. # on_json_attr_error = fail_index
  191. # json_autoconv_numbers = 1
  192. # json_autoconv_keynames = lowercase
  193. # lemmatizer_base = /usr/local/share/sphinx/dicts
  194. # lemmatizer_cache = 512M
  195. }
  196. #############################################################################
  197. ## searchd settings
  198. #############################################################################
  199. searchd
  200. {
  201. listen = 127.0.0.1:9312
  202. listen = 127.0.0.1:9306:mysql41
  203. log = /opt/sphinx/sphinxdata/logs/searchd.log
  204. query_log = /opt/sphinx/sphinxdata/logs/query.log
  205. read_timeout = 5
  206. client_timeout = 300
  207. max_children = 30
  208. persistent_connections_limit = 30
  209. pid_file = /opt/sphinx/sphinxdata/searchd.pid
  210. max_matches = 1000
  211. seamless_rotate = 1
  212. preopen_indexes = 1
  213. unlink_old = 1
  214. # attr_flush_period = 900
  215. # ondisk_dict_default = 1
  216. mva_updates_pool = 1M
  217. max_packet_size = 8M
  218. # crash_log_path = /var/db/sphinxsearch/log/crash
  219. max_filters = 256
  220. max_filter_values = 4096
  221. # listen_backlog = 5
  222. # read_buffer = 256K
  223. # read_unhinted = 32K
  224. max_batch_queries = 32
  225. # subtree_docs_cache = 4M
  226. # subtree_hits_cache = 8M
  227. workers = threads # for RT to work
  228. # dist_threads = 4
  229. binlog_path = # disable logging
  230. # binlog_path = /var/db/sphinxsearch/data # binlog.001 etc will be created there
  231. # binlog_flush = 2
  232. # binlog_max_log_size = 256M
  233. # thread_stack = 128K
  234. # expansion_limit = 1000
  235. # rt_flush_period = 900
  236. # query_log_format = sphinxql
  237. # mysql_version_string = 5.0.37
  238. # plugin_dir = /usr/local/sphinx/lib
  239. # collation_server = utf8_general_ci
  240. # collation_libc_locale = ru_RU.UTF-8
  241. # watchdog = 1
  242. # compat_sphinxql_magics = 1
  243. # predicted_time_costs = doc=64, hit=48, skip=2048, match=64
  244. # sphinxql_state = sphinxvars.sql
  245. # rt_merge_iops = 40
  246. # rt_merge_maxiosize = 1M
  247. # ha_ping_interval = 0
  248. # ha_period_karma = 60
  249. # prefork_rotation_throttle = 100
  250. # snippets_file_prefix = /mnt/common/server1/
  251. }
  252. # --eof--