user3399101
user3399101

Reputation: 1537

FATAL: no indexes found in config file '/mypath/config/development.sphinx.conf'

So, I'm using Thinking Sphinx and the heroku add-on Flying Sphinx in production.

However, I seem to be getting the below error

using config file '/mypath/config/development.sphinx.conf'...
FATAL: no indexes found in config file '/mypath/config/development.sphinx.conf'

I've read a bunch of other S.O posts but none have helped solve my issue, more specifically, I'm using acts_as_taggable gem and the tags aren't being indexed but everything else is being indexed just fine.

ThinkingSphinx::Index.define :clip, :with => :real_time do
  # fields
  indexes :name
  indexes sort_name, :sortable => true
  indexes description
  indexes taggings.tag.name, :as => :tags
end

I'm guessing it's because the taggings are an association and this is causing some issues.

What am I doing wrong?

Thanks!

Upvotes: 0

Views: 797

Answers (1)

pat
pat

Reputation: 16226

Addressed this via GitHub issues, but re-iterating here:

Method chains for fields/attributes in real-time indices must be exactly like what you'd call in your app yourself - so, taggings.tag.name is not valid. In reality, what you'd want is the following, within the context of a clip:

clip.taggings.collect(&:tag).collect(&:name)

However, that can't be applied within a Thinking Sphinx index, as it only allows for methods with no arguments. The work-around is to define a method in your model that returns a single string value of these tag names:

def tag_names
  taggings.collect(&:tag).collect(&:name).join(' ')
end

And then use that in your index definition:

indexes tag_names, :as => :tags

Now, you've changed your index definition, so you'll need to run the rake ts:regenerate rake task, because you're using real-time indices. Your question starts with indexing output, and the ts:index task only applies to SQL-backed indices, not real-time indices, so make sure you use ts:regenerate when changing index structures, and ts:generate if your Sphinx data isn't quite up-to-date (for example, if callbacks weren't fired when data was changed).

Upvotes: 1

Related Questions