Updating on Django field callables

Hello! I have auto index set to true for a model in my Django app. I have defined the fields that I want to push to the index. About 50% of those fields are callables, but when the callable is the only thing that has changed the change isn’t pushed out to the index. Wondering why that is and how best to deal with it without reindexing my entire index.

Hello!

Internally, the auto index feature rely on the post_save / post_delete signals of Django.
So if your callables do not depends on changes on the indexed models, the post_save signal won’t be fired and the changes won’t be pushed to Algolia.

Do you mind sharing a little more details about the content of your callable? Depending on this, I will be able to help you find the best way to reindex only the changes and not your full index.

Thanks,

Clement

Thanks for the response. Basically I have a property on my model that determines how old the record is and sets “flags” for use in the results (IE if the product was just put into the DB it gets a “new” flag, if it’s been there for 2 weeks that flag is removed, there are a bunch of other business rules that determine other flags as well, like on sale, or reduced for clearance etc…).

class Product(models.Model):
    inserted = models.DateTimeField()

    @property
    def flag(self):
        fdict = add_flags({'STATIC_URL': settings.STATIC_URL}, self)
        if fdict['flag']:
            return fdict['flag']['tag']
        return False

My index object has the “flag” field defined as one of the fields to submit to the index. So I’m wondering how best to deal with these without a full reindex of all my records?

1 Like

:up: on this one maybe?
The solution would be interesting for many people I suppose :innocent:

1 Like

Would love some update on this as I have yet to find a solution.

1 Like