Search code examples
mysqlruby-on-rails-3sphinxthinking-sphinx

Thinking Sphinx "no field found in schema" error


I am pretty new to Sphinx.

Trying to find user with name "bob" and company_id "14".

Controller:
@users = User.search 'bob', :conditions => { :company_id => '14'}

Model:
  define_index do
    indexes :name
    indexes :company_id
  end

Error:
index user_core: query error: no field 'company_id' found in schema

I have the 'company_id' in table & I re-indexed everything several times. When I am just searching for the 'name' everything works properly.


Solution

  • Attributes should be declared as:

    has company_id
    

    So, in you case:

    Model:
    define_index do
        indexes :name
        has :company_id
      end