Elasticsearch with django-haystack 运行 自动更新索引

Elasticsearch with django-haystack run update index automatically

我正在开发一个开放的博客网站,为了它的搜索功能,我正在使用带有 django-haystack 的弹性搜索,但问题是在每个博客之后 post 我需要 运行 命令 - python manage.py update_index,如何自动生成update_index?如果网站有数百万 posts 那么你能不能告诉我,这是个好主意还是会导致我的网站崩溃,因为我每次都需要刷新索引,我是新手请告诉我重载的正确方法搜索。 instagram 和其他社交网站使用什么搜索技术。

您可以通过将此添加到 settings.py:

来启用实时更新
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

此处有更多详细信息:

http://django-haystack.readthedocs.io/en/v2.4.1/signal_processors.html#realtime-realtimesignalprocessor

在重建索引可能需要一些时间的情况下,您应该使用队列来防止 request/response 循环受到阻碍,这里建议使用 celery 等可能的解决方案:

http://django-haystack.readthedocs.io/en/v2.4.1/other_apps.html#ref-other-apps