English 中文(简体)
Django haystack doesn t add to Solr index. [Works with whoosh, fails with 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 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.

最佳回答

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.

问题回答

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.





相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签