2
votes

I'm getting the error sort-by attribute 'published_at' not found, but only in test environment, even after rebuilding.

In the model:

belongs_to :content, polymorphic: true
belongs_to :user

define_index do
  indexes user.name, as: :name
  has role
  has user_id
  has content_id
  has content.published_at, as: :published_at, type: :datetime
  has content.status, as: :status, type: :integer
end

Running rake ts:rebuild in development properly builds the index:

# development.sphinx.conf
{
  [...]
  sql_attr_uint = sphinx_internal_id
  sql_attr_uint = sphinx_deleted
  sql_attr_uint = class_crc
  sql_attr_uint = role
  sql_attr_uint = user_id
  sql_attr_uint = content_id
  sql_attr_uint = status
  sql_attr_timestamp = published_at
  sql_attr_string = sphinx_internal_class
  [...]
}

However, running RAILS_ENV=test rake ts:config or ts:rebuild for the test environment generates this:

# test.sphinx.conf
{
  [...]
  sql_attr_uint = sphinx_internal_id
  sql_attr_uint = sphinx_deleted
  sql_attr_uint = class_crc
  sql_attr_uint = role
  sql_attr_uint = user_id
  sql_attr_uint = content_id
  sql_attr_string = sphinx_internal_class
  [...]
}

This, of course, leads to an error in the test environment:

ThinkingSphinx::SphinxError:
  index content_byline_core: sort-by attribute 'published_at' not found

Notice the missing status and published_at attributes. This has been working for the past few months, but I don't know what could have caused it to break.

  • Sphinx 2.0.2-beta
  • Thinking Sphinx 2.0.12
  • Rails 3.2.6
  • Ruby 1.9.3
1

1 Answers

0
votes

I have similar problem while using Zeus. rake spec works but when i use zeus i got similar messages did you figure that out ? For me removing zeus helps but it is only a partial solution ...