gpt4 book ai didi

python - django haystack 在生产中,如何自动执行 python manage.py update_index ?

转载 作者:太空宇宙 更新时间:2023-11-03 16:47:06 25 4
gpt4 key购买 nike

当用户上传帖子时,我使用 haystack 搜索引擎来允许用户搜索该帖子。一切都在开发中发挥作用,我担心的是在开发中我必须 python manage.py rebuild_index 才能开始,并且 python manage.py update_index 才能更新搜索引擎中添加的任何帖子。我如何在生产中自动完成这项工作?

我正在使用亚马逊 Elastic Beanstalk ,所以我想我会这样做

 01_forhaystack:
command: "source /opt/python/run/venv/bin/activate && python project/manage.py rebuild_index --noinput"

02_forhaystack2:
command: "source /opt/python/run/venv/bin/activate && python project/manage.py update_index --noinput"

它会起作用吗..?有更好的方法吗?

最佳答案

当然,您可以每天/每小时更新索引。或者甚至在每个模型插入/更新之后。但更好的方法是使用信号和 Real Time Search .

关于python - django haystack 在生产中,如何自动执行 python manage.py update_index ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36216834/

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