How can I manually reindex solr use sun spots?

I have couchdb. Sunspot indexed everything correctly. But the Solr server crashed. I need to review all of this. rake sunspot: reindex does not work because it is associated with an active recording. sunspot.index (model.all) did not work. the solr core reports 0 indexed documents even after that. is there a way out

+4
source share
3 answers

I was looking for the following:

Post.index! (Model.all)

There was something bad when I tried to index, believing that commits would happen automatically. In any case, it worked for me completely.

+3
source

Post.solr_reindex

There are a number of options that can be passed to solr_reindex. The same parameters as for the index; from the documentation

in packages of 50, fix after each

Post.index 

index all rows at once and then commit

 Post.index(:batch_size => nil) 

in batches of 50, record when all batches are completed

 Post.index(:batch_commit => false) 

includes related object + author + when loading into index

 Post.index(:include => :author) 
+14
source

I usually write the command below to index models. It works great every time.

For model ie (Post)

 Sunspot.index Post.all 

For the model line, i.e. (Post.where (id: 5))

 Sunspot.index Post.where(id: 5) 

He will work.

Hooray!

+1
source

Source: https://habr.com/ru/post/1382816/


All Articles