So I have been using solr sunspot for a couple of days and have been going a little crazy over an issue with it. I have search many different sites for the answer, but a lot of people seem to have different ideas. I am trying to figure out how sunspot manages indexing/reindexing of models in different environments with auto indexing on. This is what I have concluded:
Dev/Prod: Saving/updating an object automatically updates the indexing of that object in solr
Test: Saving/updating an object does not automatically update the index and you need to call object.reindex! in order for it to take effect.
Console: Same as testing. Reindex is required to properly update solr.
So does this look correct? It was killing me for so long whether something was wrong with my solr sunspot setup or if it just doesn't work the same in these different environments. Any help would be greatly appreciated!
After updating a document in Solr, you must issue a "commit" to tell Solr to write the changes to disk and have them start appearing in search results. Sunspot::Rails takes care of this automatically in the course of a Rails request, but outside of that (in tests, from the console), you need to do it explicitly. It's a simple Sunspot.commit
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With