Using Django and Haystack with ElasticSearch.
After installing haystack and ES and rebuild index
./manage.py rebuild_index
A WARNING. This will permanently remove TOTAL from your search index in the default connection. After that, you can restore the backups or rebuild using the rebuild_index . Are you sure you want to continue? [y / N] y
Removing all documents from your index because you said so. All documents removed. Indexing 1039 <django.utils.functional.__proxy__ object at 0x10ca3ded0>. AttributeError: 'module' object has no attribute 'ElasticSearchError'
Index update has the same problem
/manage.py update_index Indexing 1039 <django.utils.functional.__proxy__ object at 0x10ea49d90>. AttributeError: 'module' object has no attribute 'ElasticSearchError'
Clear index works fine (maybe because there is no index)
./manage.py clear_index 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 the `rebuild_index` command. Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said that. All documents are deleted.
Versions
Django stack == 2.0.0 beta
pyelasticsearch == 0.5
elasticsearch == 0.20.6
localhost: 9200 says:
{ "ok" : true, "status" : 200, "name" : "Jigsaw", "version" : { "number" : "0.20.6", "snapshot_build" : false }, "tagline" : "You Know, for Search" }
Stack Settings:
HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', 'URL': 'http://127.0.0.1:9200/', 'INDEX_NAME': 'haystack', }, }
search_indexes.py:
import datetime import haystack from haystack import indexes from app.models import City class CityIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) name = indexes.CharField(model_attr='name') state = indexes.CharField(model_attr='state') country = indexes.CharField(model_attr='country') lat = indexes.FloatField(model_attr='latitude') lon = indexes.FloatField(model_attr='longitude') alt = indexes.FloatField(model_attr='altitude') pop = indexes.IntegerField(model_attr='population') def get_model(self): return City
Any help - why am I getting an error?