用Django + Celery更新干草堆搜索索引 [英] Updating a Haystack search index with Django + Celery

查看:104
本文介绍了用Django + Celery更新干草堆搜索索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,如果这是一个基本问题,但是我搜索并找不到任何内容。在我的Django项目中,我使用的是芹菜。我从crontab转换命令是一个周期性的任务,它工作得很好,但它只是在模型上调用一个方法。是否可以从定期任务更新我的干草堆索引?有没有人这样做?

  /manage.py update_index 

这是从Haystack文档更新索引的命令,但我不知道如何从任务中调用该索引。

解决方案

最简单的方法可能是直接从python运行管理命令,并在你的任务中运行

  from haystack.management.commands import update_index 
update_index.Command()。handle()


Excuse me if this is a basic question but I searched and couldn't find anything on this. In my Django project I am using Celery. I switched over a command from crontab to be a periodic task and it works well but it is just calling a method on a model. Is it possible to update my Haystack index from a periodic task as well? Has anyone done this?

/manage.py update_index

That's the command to update the index from the Haystack documentation but I'm not sure how to call that from a task.

解决方案

the easiest way to do this would probably be to run the management command directly from python and run it in your task

from haystack.management.commands import update_index
update_index.Command().handle()

这篇关于用Django + Celery更新干草堆搜索索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆