matsko
matsko

Reputation: 22183

Searching issue with the rails-sunspot gem

I'm very new to Solr and the Rails Sunspot gem, but it looks very promising for complex searching on a big database.

What I'm trying to do is allow a model in my rails app to be searched on a few fulltext columns and then a collection of its "filters" (which are just a has_and_belongs_to_many association of names).

I tried setting up my model search block as follows

self.searchable do
  text :name, :boost => 5
  text :description, :instructions
  text :filters do
    filters.map(&:name)
  end
end

And my controller looks like so:

@search = ModelName.search do
  keywords params[:q].to_s
end

However, I cannot seem to produce any results based on keywords found in the filters association. Am I doing something wrong? This is all very new to me.

Upvotes: 1

Views: 120

Answers (1)

outoftime
outoftime

Reputation: 2200

When you initially set up your classes for search, you need to reindex the data into Solr. Have you done that? If not:

rake sunspot:reindex

Upvotes: 2

Related Questions