I'm wondering what operation should invoke after adding new entity to database to make this entity searchable with haystack:
What's problematic is that new entities will be added frequently and there might be potentially large amount of entities in db.
If you're adding new rows to your database then update_index
should be enough.
From the haystack docs:
The conventional method is to use
SearchIndex
in combination with cron jobs. Running a./manage.py update_index
every couple hours will keep your data in sync within that timeframe and will handle the updates in a very efficient batch.
If you added a new field to your search index, then you would need to run rebuild_index
:
If you have an existing
SearchIndex
and you add a new field to it, Haystack will add this new data on any updates it sees after that point. However, this will not populate the existing data you already have.In order for the data to be picked up, you will need to run
./manage.py rebuild_index
. This will cause all backends to rebuild the existing data already present in the quickest and most efficient way.