2
votes

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?

1
if you go to the analysis, put the Field as <your_field_name>_text, like country_name_text if your column is country_name. Check all boxes, and click Analyze.What do you get?Bashar Abdullah

1 Answers

2
votes

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.