如何更新 django-haystack 的单个记录?
How to update a single record for django-haystack?
我是 haystack
初学者,我正在尝试了解如何更新文档。
我有以下 SearchIndex:
class ProductIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True) # contains keywords associated with the product
name= indexes.CharField(model_attr='name')
def get_model(self):
return Product
def prepare_text(self, obj):
return [tag.keyword for tag in obj.productkeywords_set.all()]
我想在用户添加新产品关键字时更新 text
字段。我有超过80k
条记录,所以我使用python manage.py update_index
时需要很长时间。有没有办法只更新 one
文档?
The other included SignalProcessor is the haystack.signals.RealtimeSignalProcessor class. It is an extremely thin extension of the BaseSignalProcessor class, differing only in that in implements the setup/teardown methods, tying ANY Model save/delete to the signal processor.
If the model has an associated SearchIndex, the RealtimeSignalProcessor will then trigger an update/delete of that model instance within the search index proper.
Configuration looks like:
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
This causes all SearchIndex classes to work in a realtime fashion.
通过启用它,您的索引将在模型save/delete上自动更新
我是 haystack
初学者,我正在尝试了解如何更新文档。
我有以下 SearchIndex:
class ProductIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True) # contains keywords associated with the product
name= indexes.CharField(model_attr='name')
def get_model(self):
return Product
def prepare_text(self, obj):
return [tag.keyword for tag in obj.productkeywords_set.all()]
我想在用户添加新产品关键字时更新 text
字段。我有超过80k
条记录,所以我使用python manage.py update_index
时需要很长时间。有没有办法只更新 one
文档?
The other included SignalProcessor is the haystack.signals.RealtimeSignalProcessor class. It is an extremely thin extension of the BaseSignalProcessor class, differing only in that in implements the setup/teardown methods, tying ANY Model save/delete to the signal processor.
If the model has an associated SearchIndex, the RealtimeSignalProcessor will then trigger an update/delete of that model instance within the search index proper.
Configuration looks like:
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
This causes all SearchIndex classes to work in a realtime fashion.
通过启用它,您的索引将在模型save/delete上自动更新