dan
dan

Reputation: 1080

Solr returning wrong type of object

I'm using solr for search.

In my model I have -

searchable do
  integer :rank
  text :title, :descritpion
  text :aboutuser do
    users.map { |user| user.aboutuser }
  end

  text :username do
    users.map { |user| user.username }
  end
end

And then in the controller -

def index
@books = Book.search do
  fulltext params[:search]
  order_by :rank, :desc
end
...

In the server log the query looks to have the right things in it -

SOLR Request (7.0ms)  [ path=select parameters={fq: ["type:Book"], sort: "rank_i desc", q: "Every", fl: "* score", qf: "title_text descritpion_text aboutuser_text username_text", defType: "edismax", start: 0, rows: 30} ]

But rather than returning Book objects, it's returning this:

#<Sunspot::Search::StandardSearch:0x007fe6bf4f3550>

Which is causing an undefined method error when the view renders. Where am I going wrong?

Upvotes: 0

Views: 39

Answers (1)

zrl3dx
zrl3dx

Reputation: 7869

Call results to get your actual objects.

Upvotes: 2

Related Questions