[Python] How to update a single record for django-haystack?

Discussão em 'Python' iniciado por Stack, Agosto 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm a haystack beginner, and I'm trying to figure out how to update a document.

    I have the following 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()]


    I want to update the text field when a user adds a new product keyword. I have over 80k records, so it takes a very long time when I use python manage.py update_index. Is there a way to update just one document?

    Continue reading...

Compartilhe esta Página