简体   繁体   中英

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?

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.

好吧通过curl创建索引而不是重建索引使用./manage.py update_index只是为了节省一天。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM