I'm using sunspot for handling solr in my spree commerce application. I've defined it for my product model:
Spree::Product.class_eval do
searchable :auto_index => true, :auto_remove => true do
...
end
end
At index time, everything gets into Solr and works fine. But when I try to edit a product, the changes aren't saved to Solr. For example, adding a unique word like testtest
to the title of a product, and then search for that keyword returns nothing. When I reindex the whole database, it works.
Inside the sunspot.yml
I'm using the auto_commit_after_request: true
option.
I tailed the log/sunspot-solr-development.log
where every search gets logged. But it seems that editing a product doesn't make any call to Solr. I thought that using the :auto_index => true
option would trigger the saves to the database (in production I'm going to use the autoCommit
feature from Solr).
So, I'm a little bit stuck. I have no idea, where sunspot hooks into the save blocks, or is it RSolr in the background? Maybe someone can help me to fix this problem.
EDIT
I just saw, that when using Sunspot, the model class gets some methods like index
and index!
. The strange thing is, that inside the console rails c
this methods are listed when calling Spree::Product.first.methods
. But when I hook into the update method from the products controller, this methods aren't there. So maybe I have some problems during initializing the sunspot stuff.
FYI: The code from above (Spree::Product.class_eval do
) is inside an initializer under config/initializers/sunspot/sunspot_product.rb
.