ruby on rails - how to add chinese_directory config to thinking-sphinx configuration -



ruby on rails - how to add chinese_directory config to thinking-sphinx configuration -

i utilize thinking-sphinx 3.1.1, have modified sphinx version back upwards chinese character search. has special config item must set in configuration chinese_dictionary: "/usr/local/sphinx-for-chinese/etc/xdict"

i have add together "chinese_dictionay" thinking_sphinx.yml config:

thinking_sphinx.yml:

development: chinese_dictionary: "/usr/local/sphinx-for-chinese/etc/xdict" thread_stack: 1m

when generate configuration thread_stack has in developments.sphinx.conf, chinese_directory has not.

i have search argly solution, must edit hand. first generate config, rake ts:configure , set chinese_dictionary developments.sphinx.conf hand, rake ts:index index_only=true, not way.

i think can modify thinking-sphinx gems add together file rails initializers directory. have thking-sphinx gem, can not understand how modify

import: chinese_dictionary: "/usr/local/sphinx-for-chinese/etc/xdict" must under index, right config:

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 }

it's not particularly elegant, should trick (put in initializer):

module chinesedirectoryaccessor attr_accessor :chinese_dictionary end riddle::configuration::index.include chinesedirectoryaccessor riddle::configuration::realtimeindex.include chinesedirectoryaccessor riddle::configuration::indexsettings.module_eval singleton_class.send :alias_method, :old_settings, :settings def self.settings old_settings + [:chinese_dictionary] end end

it makes sure riddle (which used sphinx configuration) aware of new setting.

ruby-on-rails ruby thinking-sphinx

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -