Sphinx搜索多个配置文件导入

时间:2014-03-11 12:11:48

标签: configuration sphinx

如何在Spinx Search上使用多个配置文件(最好是在另一个中包含一个)?我需要它用于不同的环境,因为开发,阶段和生产之间的唯一区别是数据库凭据。有没有一种简单的方法来实现这一目标?

2 个答案:

答案 0 :(得分:2)

在linux上,可以使用dymamic配置文件。

即配置文件可由仲裁解析器执行。所以配置文件可以是PHP,perl甚至是shell脚本。

http://sphinxsearch.com/blog/2013/11/05/sphinx-configuration-features-and-tricks/

更多:https://www.google.com/search?q=sphinx+search+shebang

答案 1 :(得分:0)

一个老问题,但仍然值得留下答案以防万一...

indexes.conf

#!/bin/sh

my_function() {
cat << EOF
source source_$1 {
    type = csvpipe
    csvpipe_delimiter = |
    csvpipe_command = cat /input/data_file_$1.txt
    csvpipe_field_string = product_name
    csvpipe_attr_string = sku
    csvpipe_attr_string = manufacturer
    csvpipe_attr_uint = on_hand
}

index idx_$1 {
    min_infix_len = 3
    ignore_chars = U+AD,U+002D,U+00AD,U+002F,U+2044
    charset_table = 0..9, A..Z->a..z, a..z
    type = plain
    source = source_$1
    path = /var/lib/manticore/idx_$1
}
EOF
}

while IFS="" read -r p || [ -n "$p" ]
do
  my_function $p
done < index_prefixes.txt

index_prefixes.txt

abc
def
ghi
jkl
mno
pqr
stu
vwx
yz

将在下面生产样品...

source source_abc {
    type = csvpipe
    csvpipe_delimiter = |
    csvpipe_command = cat /input/data_file_abc.txt
    csvpipe_attr_bigint = dist_id
    csvpipe_field_string = product_name
    csvpipe_attr_string = sku
    csvpipe_attr_string = manufacturer
    csvpipe_attr_uint = on_hand
}
index idx_abc {
    min_infix_len = 3
    ignore_chars = U+AD,U+002D,U+00AD,U+002F,U+2044
    charset_table = 0..9, A..Z->a..z, a..z
    type = plain
    source = source_abc
    path = /var/lib/manticore/idx_abc
}

...remaining output removed for brevity...