Domanda

How can you use multiple config files on Spinx Search (preferably by including one inside another)? I need it for different environments, because the only difference between development, stage and production is the database credentials. Is there an easy way to achieve this?

È stato utile?

Soluzione

On linux, can use dymamic config files.

ie the config file can be executed by arbitary parsers. So the config file could be a PHP, perl or even shell script.

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

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

Altri suggerimenti

An old question, but still worth leaving an answer in case it helps...

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

will produce sample below...

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...
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top