Django haystack 不添加到 Solr 索引。 [与 whoosh 配合使用,与 Solr 配合使用失败]
在开发过程中,我使用 whoosh 作为后端,现在想切换到 索尔。我安装了 solr,更改了设置,以 HAYSTACK_SEARCH_ENGINE 和 HAYSTACK_SOLR_URL。
现在,当我尝试更新或重建索引时,它失败了 无法将文档添加到 Solr:[原因:无]
。
所有搜索也都是错误的,所有查询返回 0 个结果。 如果我改成嗖嗖的,这个就可以了。不过,我有一个实时搜索 索引集,并且在模型创建过程中我没有收到任何警告 能够写入搜索索引。 (从中我假设数据正在正确写入 solr 索引。
我可以通过直接进入 solr 启动的端口来看到 solr 正在运行。
During development I used whoosh as a backend, and now want to switch to
solr. I installed solr, changed the settings, to
HAYSTACK_SEARCH_ENGINE, and HAYSTACK_SOLR_URL.
Now when I try to update or rebuild the index it fails withFailed to add documents to Solr: [Reason: None]
.
All searches are also wrong with 0 results returned for all queries..
This work if I change to whoosh. However, I have a RealTimeSearch
index set, and during model creation I am getting no warning about not
being able to write to search index. (From which I am assuming that data is being correctly being written to solr index.
I can see that solr is running by going directly to the port where solr started.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您的 schema.xml 文件配置不正确时,通常会发生此错误。
您可以使用 python manage.py build_solr_schema > schema.xml 生成架构。
为了真正让 solr 使用它,您通常将其放置在
example/solr/conf/schema.xml
最后:观察 Solr 服务器的日志输出。在开发过程中,我通过 java -jar start.jar 运行它,并隐式打印到我的屏幕上。否则,您的日志将进入
example/logs
目录。此外,请仔细检查
HAYSTACK_SOLR_URL
。它不应有尾部斜杠。This error usually happens when your schema.xml file is improperly configured.
You can use
python manage.py build_solr_schema > schema.xml
to generate the schema.In order to actually have solr use it, you typically place it in
example/solr/conf/schema.xml
Finally: watch the log output of your Solr server. During development I have it running via
java -jar start.jar
and it implicitly prints to my screen. Otherwise, your logs go into theexample/logs
directory.Additionally, double check the
HAYSTACK_SOLR_URL
. It should not have a trailing slash.我遇到了这个错误。第一个原因是我没有重建 schema.xml,但还有更多原因......重建 schema.xml 后,您必须重新启动 Solr。这样做,Solr 将识别模式更改并了解新字段。
I was having this error. The first reason was that I hadn't rebuilt the schema.xml, but there is something more... After you rebuild the schema.xml you must to restart Solr. Doing this, Solr will recognize the schema changes and will know the new fields.