【问题标题】:Sphinx Search multiple config files importSphinx 搜索多个配置文件导入
【发布时间】:2014-03-11 12:11:48
【问题描述】:

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

【问题讨论】:

    标签: configuration sphinx


    【解决方案1】:

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

    即配置文件可以由任意解析器执行。所以配置文件可以是 PHP、perl 甚至是 shell 脚本。

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

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

    【讨论】:

      【解决方案2】:

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

      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...
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-11-30
        相关资源
        最近更新 更多