简体   繁体   English

IndexMissingException - 带有elasticsearch的django haystack

[英]IndexMissingException - django haystack with elasticsearch

I am trying to setup haystack search with elasticsearch backend I am receiving the following error: 我正在尝试使用elasticsearch后端设置haystack搜索我收到以下错误:

./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 我正在运行Django 1.4.2,来自github的django-haystack HEAD和来自github的pyelasticsearch HEAD

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. 我没有根据haystack 2的要求从index.Indexable扩展我的Index类。因此,haystack根本没有拾取我的索引并在没有另行通知的情况下正确完成。 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. 如果你调用rebuild_index,干草堆似乎总是给它,无论索引是否已经存在。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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