Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IndexMissingException - django haystack with elasticsearch

I am trying to setup haystack search with elasticsearch backend I am receiving the following error:

./manage.py rebuild_index
 ...
Failed to clear Elasticsearch index: (404, u'IndexMissingException[[haystack] missing]')

However, the following command works:

curl -XPUT http://33.33.33.1:9200/haystack
{"ok":true,"acknowledged":true}
curl -XGET http://33.33.33.1:9200/haystack/test/something
{"_index":"haystack","_type":"test","_id":"something","exists":false}

Now, after running

./manage.py rebuild_index
...
Failed to clear Elasticsearch index: (404, u'IndexMissingException[[haystack] missing]')

again, suddenly the command that worked as expected now gives the following error:

curl -XGET http://33.33.33.1:9200/haystack/test/something
{"error":"IndexMissingException[[haystack] missing]","status":404}

As suggested in other places I also tried:

from django.core import management
from haystack import connections
backend = connections['default'].get_backend()
backend.setup_complete = False
backend.existing_mapping = None
management.call_command('rebuild_index', interactive=False, verbosity=0)

with the same result:

{"error":"IndexMissingException[[haystack] missing]","status":404}

I am running Django 1.4.2, django-haystack HEAD from github and pyelasticsearch HEAD from github

config:

HAYSTACK_CONNECTIONS = {
  'default': {
    'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
    'URL': 'http://33.33.33.1:9200/',
    'INDEX_NAME': 'haystack',
  },  
}  

Can anyone help me?

like image 724
phlebas Avatar asked Dec 03 '12 09:12

phlebas


1 Answers

Stupid me. I did not extend my Index class from indexes.Indexable as required by haystack 2. Therefore haystack simply did not pickup my index and finished correctly without further notice. The error message is somewhat misleading. Haystack seems to always give it if you invoke rebuild_index, no matter if the index already existed or not.

like image 149
phlebas Avatar answered Oct 20 '22 20:10

phlebas