Reputation: 7996
I'm using Django and the Haystack module to create a search engine. I want to use ElasticSearch. I have installed it and launched it with:
$ brew install elasticsearch
$ elasticsearch -f -D es.config=/usr/local/Cellar/elasticsearch/0.90.2/config/elasticsearch.yml
My settings seem correct and work:
# Haystack configuration
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:8000/',
'INDEX_NAME': 'haystack',
},
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
Here is my search indexes:
from haystack import indexes
from account.models import Profile
class ProfileIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
first_name = indexes.CharField(model_attr='first_name')
last_name = indexes.CharField(model_attr='last_name')
def get_model(self):
return Profile
and my profile_text.txt:
{{ object.first_name }}
{{ object.last_name }}
Everything seems correct I guess, I follow the documentation and this tutorial.
But now, when I'm triggering:
$ python manage.py rebuild_index
I get this error:
pyelasticsearch.exceptions.InvalidJsonResponseError: <Response [404]>
If someone knows why? :)
Thank you.
Upvotes: 1
Views: 262
Reputation: 47212
You're running the Elastic Search Server on the same port as the Django Server is running on.
Change the port from 8000
to something else, and then it'll work!
Upvotes: 1