Ruby 我能';我不能让斯芬克斯为我的模型编制索引

Ruby 我能';我不能让斯芬克斯为我的模型编制索引,ruby,ruby-on-rails-3,rubygems,sphinx,thinking-sphinx,Ruby,Ruby On Rails 3,Rubygems,Sphinx,Thinking Sphinx,我试图使用命令ts:index,但它抛出了一个错误 rake ts:index Generating configuration to /home/rbennacer/Desktop/projects/guest_database_project/config/development.sphinx.conf Sphinx 2.1.4-release (rel21-r4421) Copyright (c) 2001-2013, Andrew Aksyonoff Copyright (c) 2008

我试图使用命令ts:index,但它抛出了一个错误

rake ts:index
Generating configuration to /home/rbennacer/Desktop/projects/guest_database_project/config/development.sphinx.conf
Sphinx 2.1.4-release (rel21-r4421)
Copyright (c) 2001-2013, Andrew Aksyonoff
Copyright (c) 2008-2013, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/home/rbennacer/Desktop/projects/guest_database_project/config/development.sphinx.conf'...
FATAL: no indexes found in config file '/home/rbennacer/Desktop/projects/guest_database_project/config/development.sphinx.conf'
所以我在某个地方读到,我安装sphinx的方式是错误的,我需要从源代码处编译它以支持postgres。我跟着这个

我仍然得到同样的错误

以下是一些重要文件:

cat config/development.sphinx.conf 

indexer
{
}

searchd
{
  listen = 127.0.0.1:9306:mysql41
  log = /home/rbennacer/Desktop/projects/guest_database_project/log/development.searchd.log
  query_log = /home/rbennacer/Desktop/projects/guest_database_project/log/development.searchd.query.log
  pid_file = /home/rbennacer/Desktop/projects/guest_database_project/log/development.sphinx.pid
  workers = threads
  binlog_path = /home/rbennacer/Desktop/projects/guest_database_project/tmp/binlog/development
}
模型:

class Person < ActiveRecord::Base
  attr_accessible :alignment, :gender, :source, :ethnicity, :description, :first_name, :last_name , :profession_ids, :roles_attributes

  # avoid duplicate
  validate :first_name,  :presence => true, :uniqueness => {:scope => :last_name}, :message => "that name existe already"


  #professions
  has_many :personProfessions
  has_many :professions , :through => :personProfessions

  #tvshows
  has_many :tvShowHosts
  has_many :tvShows , :through => :tvShowHosts ,:foreign_key=>"tv_show_id"#,:source=> :person#, :foreign_key=>"person_id"

  #segments
  has_many :personSegments
  has_many :segments , :through => :personSegments

  #organizations and postions
  has_many :roles
  has_many :organizations, through: :roles
  has_many :positions, through: :roles

  accepts_nested_attributes_for :roles,
    :allow_destroy => true,
    reject_if: lambda { |role| role[:organization_id].blank? || role[:position_id].blank? }
  def full_name
    "#{first_name} #{last_name}"
  end


  # def roles_attributes=(attributes)
  #   puts "roles_attributes=#{attributes}"
  #   roles = attributes.values   

  # end   

  define_index do
    # indexes content
    # indexes :name, sortable: true
    # indexes comments.content, as: :comment_content
    indexes [first_name,last_name], as: :name

    # has author_id, published_at
  end
end
class-Persontrue,:university=>{:scope=>:last\u name},:message=>“该名称已存在”
#职业
你有很多职业吗
有许多:职业,:通过=>:个人职业
#电视节目
有很多电视节目主持人吗
有很多:电视节目,:通过=>:电视节目主持人,:外键=>“电视节目id”;:来源=>:人物,:外键=>“人物id”
#分段
有很多:个人部分
有多个:段,:至=>:personSegments
#组织和职位
有很多:角色
有很多:组织,通过::角色
有很多:职位,通过::角色
接受以下角色的\u嵌套\u属性\u,
:allow_destroy=>true,
如果:lambda{| role | role[:organization_id]。空白?| | role[:position_id]。空白?}
def全名
“#{姓}#{姓}”
结束
#def角色_属性=(属性)
#放置“角色属性={attributes}”
#角色=属性。值
#结束
定义索引do
#索引内容
#索引:名称,可排序:true
#索引comments.content,作为::comment\u content
索引[名字,姓氏],如::name
#作者id已发布在
结束
结束

定义索引
在ts的较新版本中无效。定义索引的新方法在“应用程序/索引”下

您必须将索引移动到app/index/person.rb文件:

ThinkingSphinx::Index.define :person, :with => :active_record do
  indexes [first_name,last_name], as: :name
end

请参阅

上的用法部分,修复了它:我在我的
数据库.yml中使用了sqlite,而不是postgres,语法是错误的。

你能从Gemfile.lock中提到你正在使用的thinking sphinx的版本吗?我在我的数据库.yml中使用了sqlite