At least one field is necessary for an index

19 views
Skip to first unread message

Hendra Gunawan

unread,
Feb 29, 2012, 9:21:58 AM2/29/12
to thinkin...@googlegroups.com
I have my RoR Application with Rails 3.1.3
I try to run "rake ts:config", but it always return error "At least one field is necessary for an index",  any body can help me to solve this problem?

I think I already define index in my model, Training, but when I run rake task to generate ts configuration, it always return error.

Here is my model:

# == Schema Information
#
# Table name: trainings
#
#  id          :integer(4)      not null, primary key
#  user_id     :integer(4)
#  name        :string(255)
#  description :text
#  created_at  :datetime
#  updated_at  :datetime
#
class Training < ActiveRecord::Base

  # attributes
  attr_accessor :training_tags

  # relations
  belongs_to :user

  has_many :training_tag_relations
  has_many :tags, :through => :training_tag_relations

  # return flatten tag in array
  def flatten_tag
    tags.map { |t| t.name }
  end

  # call back after create
  after_create :create_training_tags

  # define index for mapping
  define_index do
    # field
    index   :name, :sortable => true
    index   :description
    index   tags.name, :as => :tag_name

    # attribetus
    has :user_id, :created_at, :updated_at
  end

end

Pat Allan

unread,
Feb 29, 2012, 6:24:18 PM2/29/12
to thinkin...@googlegroups.com

Hi Hendra

I think you have a syntax error in your definition - it should be 'indexes' not 'index' for each field.

Cheers

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/IUmro6olVIIJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.

Reply all
Reply to author
Forward
0 new messages