I cannot get index.remove_object to actually follow through with removing the object. They continue to appear in the index even after deleting them.
I have tried via the signal processor as well as manually in the shell. I get no error messages, but the object still shows up via SearchQuerySet.
Here is the relevant code:
### search_index.py ###
class BookIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.EdgeNgramField(document=True, use_template=True)
id = indexes.IntegerField(indexed=False, stored=True, model_attr='id')
### shell ###
from haystack import connections
from haystack.query import SearchQuerySet
from .models import Book
book_object = Book.objects.first()
SearchQuerySet().filter(id=book_object.id).count()
--> 1
index = connections['default'].get_unified_index().get_index(Book)
index.remove_object(book_object, using='default')
SearchQuerySet().filter(id=book_object.id).count()
--> 1
book_object.delete() # RealTimeSignalProcessor fires here, confirmed via print statement, no errors
SearchQuerySet().filter(id=book_object.id).count()
--> 1
# Update does work, though, as seen below:
another_book_object = Book.objects.last()
another_book_object.name
--> 'The Shining'
SearchQuerySet().filter(name='The Shining').count()
--> 1
another_book_object.name = 'Lord of the Rings'
another_book_object.save() # RealTimeSignalProcessor fires here
SearchQuerySet().filter(name='The Shining').count() # No longer finds 'The Shining' in index because it has been updated
--> 0
I can even add a print statement to the signalprocessor that shows the code is firing, but for some reason the index itself isn't updating. The object does disappear if I run rebuild_index, but I don't want to have to do that each time I delete something.
index.update_object is working just fine, and new values are reflected in the index. But remove_object does not.
Any thoughts?