2014-11-04 2 views
0

스핑크스 검색 엔진에 대한 내 mysql 데이터베이스의 색인을 생성하려고했는데 그게 제가 얻은 것입니다. 나는 전체적인 stackoverflow를 거쳐 내 레일을 다운 그레이드했고, 스핑크스와 ts를 5 ~ 6 번 업데이트했다. 나는 내 코드를 두 번 확인했다 (어쩌면 문제가있을 수있다). 나는 config.threadsafe를 평가했다! 그리고 다른 것은 무엇이든 여전히 작동하지 않습니다. 아마 너는 나를 도와 줄 수있을거야. 여기RoR - rake rs : Rails 4.0.4 (4.1.7)에서 NameError로 인해 색인이 실패하고 스핑크스가 3.1.1이되었습니다.

pchudinov:xxx chud$ rake ts:index 
/Library/Ruby/Gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
DEPRECATION WARNING: config.threadsafe! is deprecated. Rails applications behave by default as thread safe in production as long as config.cache_classes and config.eager_load are set to true. (called from <class:Application> at /xxx/config/application.rb:29) 
searchd is not currently running. 
Stopped searchd daemon (pid:). 
Generating configuration to /xxx/config/development.sphinx.conf 
rake aborted! 
NameError: uninitialized constant RealTeams 
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:226:in `const_get' 
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:226:in `block in constantize' 
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `each' 
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `inject' 
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `constantize' 
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/core_ext/string/inflections.rb:66:in `constantize' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/core/index.rb:43:in `model' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/active_record/index.rb:9:in `append_source' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/active_record/interpreter.rb:63:in `__source' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/active_record/interpreter.rb:20:in `indexes' 
/xxx/app/indices/real_teams_index.rb:2:in `block in <top (required)>' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/core/interpreter.rb:3:in `translate!' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/core/index.rb:39:in `interpret_definition!' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/active_record/index.rb:32:in `sources' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration/consistent_ids.rb:31:in `collect' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration/consistent_ids.rb:31:in `sources' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration/consistent_ids.rb:19:in `attributes' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration/consistent_ids.rb:23:in `sphinx_internal_ids' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration/consistent_ids.rb:7:in `reconcile' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration.rb:87:in `render' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration.rb:96:in `block in render_to_file' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration.rb:96:in `open' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/configuration.rb:96:in `render_to_file' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/rake_interface.rb:13:in `configure' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/rake_interface.rb:24:in `index' 
/Library/Ruby/Gems/2.0.0/gems/thinking-sphinx-3.1.1/lib/thinking_sphinx/tasks.rb:9:in `block (2 levels) in <top (required)>' 
Tasks: TOP => ts:index 
(See full trace by running task with --trace) 

"RealTeam"에 대한 원래의 코드입니다 :

컨트롤러 :

def search 
     @real_teams = RealTeam.search params[:search] 
    end 

모델 :

class RealTeam < ActiveRecord::Base 
    has_many :players 
    has_many :home_matches, :class_name => 'Match', :foreign_key => 'team_home_id' 
    has_many :away_matches, :class_name => 'Match', :foreign_key => 'team_away_id' 
    has_many :performances 
end 

여기에 콘솔 로그 및 원본 코드의 일부는 색인 :

ThinkingSphinx::Index.define :real_teams, :with => :active_record do 
    indexes :name 
end 

P. 나는 레일과 공통점이 없지만, 코드가 제대로 수행되었다고 생각한다.

답변

0

색인 정의는 :real_teams 대신 :real_team (단수, 모델 이름과 유사 함)을 참조해야합니다.

+0

해결되지 않음 : c –