Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reindexing a particular model in Sunspot seems to make no difference in time taken

Tags:

solr

sunspot

My application usually takes 20 minutes to reindex as a whole. There is a small table with a couple of records which I want to reindex again. I want to save time so I ran the command rake sunspot:solr:reindex[500,Deal]. This is taken straight from the Github readme and is suppose to reindex one model only.

The time it takes to reindex in this command is still 20 minutes, so there is no difference in the time taken. Am I doing something wrong?

like image 838
lulalala Avatar asked Dec 30 '11 01:12

lulalala


2 Answers

I was in the same situation of you asking why it takes the same time.

The solution: erase the ":solr". Just write:

rake sunspot:reindex[batch_size,Model]

If you don't specify the batch_size you have tu put a comma "," like:

rake sunspot:reindex[,model]
like image 161
francordie Avatar answered Nov 17 '22 16:11

francordie


I now go into Rails console and call reindex from there:

Deal.solr_reindex(:batch_size => 1000, :include => :period)

This works great as I can now reindex only one model, include related tables to improve speed. Previously it is only indexing at 200/sec, and now it is at 1000/sec.

(In fact, since reindexing through console or rake will clear the index file, resulting in a short period of empty index, I now call solr_index most of the time to update the index.)

like image 38
lulalala Avatar answered Nov 17 '22 16:11

lulalala