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

标签 python django amazon-elastic-beanstalk

当用户上传帖子时,我使用 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/

相关文章:

python - Tkinter 按钮图像为空白

python - SerializerMethodField 的函数 get_fieldname 未被调用

node.js - Bcrypt Elastic beanstalk nodejs 部署

即使更改了几个文件,Git 也会推送整个项目。 AWS

python - 带导入的全局变量

python - 如何在 GtkTextView 中插入 UTF8 文字?

python - 运行动态编译的代码对象时,如何在回溯中保留源代码行?

django - 使用 ansible 而不是 pip2 安装 pip3 包

python - 在 Django 中放置额外启动代码的正确位置?

debugging - 在 aws elastic beanstalk 上部署 Node js Web 应用程序 - 显示 502 bad gateway nginx/1.8.0