The sun of the sun in different environments

So, I use solr sunspot for a couple of days and am a little embarrassed about the problem with it. I am looking for many different sites for an answer, but many people have different ideas. I am trying to understand how sunspot manages indexing / reindexing of models in different environments with automatic indexing. Here is what I did:

Dev / Prod: saving / updating an object automatically updates the indexing of this object in solr

Test. Saving / updating an object does not automatically update the index, and you need to call object.reindex! for it to take effect.

Console: Same as testing. Reindex is required to properly update solr.

So does it look right? It has been killing me for so long, something is wrong with my solr sunspot setting, or if it just doesn't work the same in these different environments. Any help would be greatly appreciated!

+3
source share
2 answers

After updating the document in Solr, you should issue a β€œcommit” to tell Solr to write the changes to disk and start searching for them in the search results. Sunspot :: Rails does this automatically during a Rails request, but outside of this (in tests, from the console) you need to do this explicitly. It is simple Sunspot.commit.

+7
source

There are three main ways to update an index:

  • object.index: puts an object for indexing, but cannot be indexed immediately
  • object.index!:
  • Class.reindex: .

, .index! .index .

+1

All Articles