Rails not returning correct results
I have a Foo model with an attribute named listed
.
Now I am running a simple sunspot request (solr)
foos = Foo.search do
with :listed, true
end.results
It returns all foos that have listed = true
but two of them.
I've already tried the following:
Sunspot.remove_all
Foo.solr_index
Sunspot.commit
Foo.all.each(&:index!)
Any help would be much appreciated.
source to share
In my case, I used a gem called "act_as_paranoid" so that after deleting the object, I can restore it. Once an object has been destroyed, it remains in the "deleted" limbo state forever, unless I issue a command to permanently delete it. This was my problem. Solr Sunspot still has the indices of these deleted items, but was unable to get it.
What I've done:
- Permanently remove all items in limbo
- Reindex all objects belong to this model
Voila! Everything returns correctly.
I went through yesterday and it was even better when combining the built-in breakdown on photos, but that's a different story.
Hope you are similar.
source to share