Django haystack doesn't add to Solr index. [Works with whoosh, fails with Solr]

一曲冷凌霜 提交于 2019-12-21 20:54:43

问题


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 with Failed 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.


回答1:


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 the example/logs directory.


Additionally, double check the HAYSTACK_SOLR_URL. It should not have a trailing slash.




回答2:


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.



来源:https://stackoverflow.com/questions/2219945/django-haystack-doesnt-add-to-solr-index-works-with-whoosh-fails-with-solr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!