我正在为我的搜索页面使用带有 ElasticSearch 后端的 Django Haystack。我使用 MongoDB 作为我的数据库。
在我的搜索页面中一切正常。
问题
我的 Web 应用程序使用外部脚本使用 pymongo 更改后端数据库中的字段
我的数据库有 2 个字段(文件、分析)。
第三方脚本运行并将分析字段更改为 True 或 False。
脚本运行后,当我搜索文件名时,它会在结果中显示更新后的分析。
但是当我搜索 Analysis Field时,(比如说我搜索 True/False )它没有列出当前更新的 Analysis,尽管它已经更新了。
例如
搜索:文件名
结果:文件名真
搜索 : True
结果 : 未找到结果
它仅在我 update_index 之后才起作用
我尝试了什么
所以我发现我必须更新索引。但我不知道如何从外部 python 脚本更新。
我试着跑步
os.system("python /myapp/manage.py update_index")
我得到错误
Unknown command: 'update_index'
当我检查外部脚本中可用的管理命令时,它没有列出 haystack 命令。
os.system("python /myapp/manage.py")
Available subcommands:
[auth]
#Things under [auth]
[contenttypes]
#Things under [contenttypes]
[django]
#Things under [django]
[sessions]
#Things under [sessions]
[staticfiles]
#Things under [staticfiles]
与我在终端中运行的相反,这里没有显示 haystack 子命令。
如果我在终端上运行
#other subcommands
[haystack]
build_solr_schema
clear_index
haystack_info
rebuild_index
update_index
所以我期望结果
Search :True
Results : filename True
我如何做到这一点?
如何从外部脚本更新索引?
还有其他想法吗?