I'm using django-haystack (v 2.3.1) with solr (v 5.0.0) and pysolr (v 3.0.0). I've been following the tutorial, and have set up similar myapp/search_indexes.py
and search/indexes/myapp/mymodel_text.txt
files.
./manage.py build_solr_schema > schema.xml
works fine, and I have copied this to $SOLR_HOME/conf/schema.xml.
The problem occurs when I try ./manage.py rebuild_index
. First, I'm asked to confirm:
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via therebuild_index
command.
Are you sure you wish to continue? [y/N] y
Then, it fails:
Removing all documents from your index because you said so.
Failed to clear Solr index: [Reason: Error 404 Not Found]
All documents removed.
Indexing 6 stories
Failed to add documents to Solr: [Reason: Error 404 Not Found]
My connection settings are:
#settings.py
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr',
},
}
If I navigate to this url I can see the solr admin page. I have made sure that port 8983 is open for solr (as well as 8000 for the Django development server).
I feel that I may not have provided enough connection information, but what else is there to check?
UPDATE:
Although I solved this problem there were more to come, which were all fixed by using solr (v.4.7.0) instead, as django-haystack isn't ready for solr 5 (there was an issue related to this but I can no longer find it on github.
Thanks to user366722 for suggesting to specify the core in the settings. However, I had neglected an even more fundamental step of creating the core!
Solution:
Create the core, specifying the name of the core (e.g. 'default') and the port (e.g. 8983):
$bin/solr create_core -c default -p 8983
Then, just specify the name of the core (e.g. 'default') in your haystack URL settings:
#settings.py
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr/default',
},
}
Done!
Now, I get
Removing all documents from your index because you said so.
All documents removed.
Indexing 3 stories
UPDATE:
At the time of writing, I also switched to solr 4.7.0 to make it work, as haystack wasn't ready for solr 5.x
Had the same problem and found the answer: https://stackoverflow.com/a/29833997/366722 You need to specify the core in your URL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With