gpt4 book ai didi

python - 添加新实体后的 Django haystack 索引

转载 作者:太空宇宙 更新时间:2023-11-04 05:53:25 25 4
gpt4 key购买 nike

我想知道在将新实体添加到数据库后应该调用什么操作才能使这个实体可以用 haystack 搜索:

  • 我应该只更新索引吗?
  • 我应该重建整个索引吗?

有问题的是,新实体将被频繁添加,并且数据库中可能存在大量实体。

最佳答案

如果您要向数据库中添加新行,那么 update_index 就足够了。

来自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.

如果您向搜索索引添加了一个新的字段,那么您需要运行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.

关于python - 添加新实体后的 Django haystack 索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29017509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com