1
votes

I am trying to use sunspot solr for searching with Rails 4 and mysql.

I defined a searchable block in my model(eg XYZ):

searchable do
  text :name, :stored => true
  string :id, :stored => true
end 

I just want to search in "name". The "id" is the primary key. There are many other columns in the table that have nothing to with this search, so I did not include them in the searchable block.

Now, when I perform a search eg "go".. it gived my the results I want exactly. However, this line is displayed on the log/console.

Completed 200 OK in 126ms (Views: 0.0ms | ActiveRecord: 11.0ms | Solr: 33.0ms)

I want to remove the active record/db hit completely. Thats why I had specified :stored => true. But the db hit is still there. It is performing:

select XYZ.* from XYZ where XYZ.id in (list of the id's which satisfy the search criteria)

Is it possible to completely remove it and for sunspot:solr to search only in the stored index and give the result?

Thanks.

1

1 Answers

0
votes

How are you accessing the result? If you are calling .results method then it will fire db query. You should iterate over hits and get the require field to avoid db query.