从干草堆索引中删除对象 [英] Remove object from haystack index
问题描述
我使用Django删除记录:
I delete a record using django:
r = model.objects.get(id=1)
r.delete()
现在,我想从索引中删除记录,而无需重新编制索引.怎么样?
Now I want to remove the record from the index WITHOUT re-indexing. How?
我无法使remove_object工作,并且干草堆文档也是高水平.我不能只运行"python manage.py update_index-remove",因为这也会重新索引所有内容.
I cannot get remove_object to work and the haystack docs are too high level. I cannot just run "python manage.py update_index -- remove" because this will also re-index everything.
推荐答案
哈,答案很简单,但很客气.基本上,下面的代码有效,因为如果您选择正确的时间(最近一个小时在数据库中没有条目),它将仅删除已删除记录的索引条目.瞧!
Ha, the answer was simple, yet hacky. Basically, the following code works, because if you time it right (no entries in the db in the last hour) it will only remove index entries for records that have been deleted. Voila.
python manage.py update_index --remove --age=1
这篇关于从干草堆索引中删除对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!