berkes
berkes

Reputation: 27553

Debugging Mongoid and Sunspot SOLR

I am fiddling with sunspot and SOLR sunspot, trough sunspot mongoid. Everything seems to work fine, but I am not getting search results back.

The solr admin on http://0.0.0.0:8982/solr/admin/ tells me that there are items indexed, though I have too little knowledge to interprete the exact indexes there. Also, searching through that interface does not give me results either.

I am rather new to SOLR: I have implemented it successfully with a "generic" active-record/mysql Rails app in the past; but not with mongoID.

The problem might be anywhere: not correctly indexed, not correctly retrieved, not correctly passed trough sunspot and so on.

Is it a good idea to start at the solr side first? Throw some requests over HTTP to it, to see if it is actually indexing stuff? If so, how? Or should I fiddle in rails first, see if it is getting some XML back but parsing or interpreting it wrong?

Upvotes: 2

Views: 1204

Answers (1)

Chris Slade
Chris Slade

Reputation: 8235

So I was having the same problem, and I also noticed that it wouldn't reindex my results. Then I found the sunspot_mongo gem. Use it instead of sunspot_mongoid

In your gemfile

gem 'sunspot_mongo'

Then in your models

include Sunspot::Mongo

Then instead of calling search in your controllers do:

Model.solr_search do
  fulltext params[:q]
end

Also, to reindex do rake sunspot:mongo:reindex

I think rake sunspot:reindex just tries to index your sqlite database that your probably not using.

Upvotes: 2

Related Questions