Building Solr indexes through Haystack throws unknown field error
-
21-09-2019 - |
Question
I'm trying to integrate Haystack with Solr. When I try to build the index, I get an error "Unknown field django_id" from SOLR. What's causing this to happen?
Solution 2
The schema.xml was malformed as I had copied additional text from the console.
OTHER TIPS
You also get this error if you haven't given Solr the schema.xml file which Haystack generates for you, as explained here in the docs.
django-haystack.readthedocs.io/en/latest/tutorial.html#reindex
If you added new fields to your database and copied the generated XML files from Haystack, you might also be getting this error because you haven't restarted jetty/Tomcat/whatever server you are using. This solved it for me on Ubuntu and Jetty:
sudo /etc/init.d/jetty stop
sudo /etc/init.d/jetty start
(by the way, that would also be the same as simply doing this):
sudo service jetty restart
Or, if you are using tomcat, that would be
sudo service tomcat6 restart
Edit: (tested this with Tomcat, and it solved the same problem again, the same as with Jetty).