问题
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