我是用思维-斯芬克斯3.1.1,我有一个修改的斯芬克斯版本支持汉字搜索。它有一个特殊的配置项必须放在配置chinese_dictionary中:“/usr/local/sphinx/etc/xdict”
我在chinese_dictionay中添加了“thinking_sphinx.yml”--这是我的配置:
thinking_sphinx.yml:
开发:"/usr/local/sphinx-for-chinese/etc/xdict" chinese_dictionary: thread_stack: 1M
当我生成只有thread_stack在developments.sphinx.conf中的配置时,chinese_directory没有。
我已经搜索了一个阿格利解决方案,它必须手工编辑。首先生成配置,rake :配置,将chinese_dictionary手动放到developments.sphinx.conf,然后rake :索引INDEX_ONLY=true,我不喜欢这样。
我认为它可以通过在rails初始化器目录中添加一个文件来修改thinking宝石。我已经看过了,但是我不知道该怎么修改。
导入: chinese_dictionary:“/usr/local/sphinx/etc/xdict”必须在索引下面,这是正确的配置:
index article_core
{
type = plain
path = ~Documents/Project/blog/db/sphinx/development/article_core
docinfo = extern
charset_type = utf-8
source = article_core_0
chinese_dictionary = /usr/local/sphinx-for-chinese/etc/xdict
}
index article
{
type = distributed
local = article_core
}发布于 2014-06-22 09:45:42
它并不特别优雅,但这应该能做到这一点(把它放在初始化器中):
module ChineseDirectoryAccessor
attr_accessor :chinese_dictionary
end
Riddle::Configuration::Index.include ChineseDirectoryAccessor
Riddle::Configuration::RealtimeIndex.include ChineseDirectoryAccessor
Riddle::Configuration::IndexSettings.module_eval do
singleton_class.send :alias_method, :old_settings, :settings
def self.settings
old_settings + [:chinese_dictionary]
end
end它确保Riddle (用于Sphinx配置)知道新设置。
https://stackoverflow.com/questions/24320631
复制相似问题