Rails Sunspot/Solr Index Out of Sync

200 Views Asked by At

I'm using the sunspot-rails gem for searching and filtering but am running into issues where Solr queries are not returning the correct results. For example, say I want to retrieve all the records of a model with state == Processing, and I do the following Sunspot search:

MyModel.search do
    # pagination and ordering stuff
    ...
    with('state', 'Processing')
    ...
end

Most of the time, this returns the correct results. Sometimes (and so far only on production, I can't duplicate the issue locally) the query will return records with state == In Review. If I do a regular ActiveRecord MyModel.where(state: 'Processing') I always get the correct results.

I thought it might have to do with my solrconfig.yml file but changing those params haven't seemed to change anything. Relevant portion of that file:

<autoCommit>
   <maxTime>15000</maxTime>
   <maxDocs>1000</maxDocs>
   <openSearcher>true</openSearcher>
 </autoCommit>

<autoSoftCommit>
   <maxTime>5000</maxTime>
 </autoSoftCommit>

Does anyone have any pointers for why changes in my db aren't reflected in the Solr index, or how I can debug/log what's going on? This is on a small internal app with maybe 100 users or so. I shouldn't have to reindex Solr daily to keep the results up to date.

Thanks.

0

There are 0 best solutions below