简体   繁体   English

elasticsearch(Python / Django)批量索引编制没有索引错误

[英]elasticsearch (Python/Django) bulk indexing throws No Index error

I am using elasticsearch 's python client and elasticsearch-dsl as well. 我也在使用elasticsearch的python客户端和elasticsearch-dsl I have created an index IndexName and I validated the existence of the index. 我创建了一个索引IndexName并验证了索引的存在。 I have a doc_type DocumentModelIndex associated with this IndexName . 我有一个与此IndexName相关联的doc_type DocumentModelIndex

def bulk_indexing():
        from app.models import DocumentModel
        DocumentModelIndex.init(index=settings.ES_INDEX)
        es = Elasticsearch()
        bulk(client=es,actions=(b.indexing() 
                for b in DocumentModel.objects.all().iterator()))

When I run the above code I get the following error: ValidationException: No index . 当我运行上面的代码时,出现以下错误: ValidationException: No index

I tried Putting a document into that index using: curl -XPOST " http://localhost:9200/index_name/document_model_index/ " -d "{\\"source\\":\\"google\\"}" and this worked. 我尝试使用以下命令将文档放入该索引中:curl -XPOST“ http:// localhost:9200 / index_name / document_model_index / ” -d“ {\\” source \\“:\\” google \\“}”,并且可以正常工作。

I am new to elasticsearch and am not able to figure this out. 我是elasticsearch新手, elasticsearch这个问题。 Any help would be much appreciated! 任何帮助将非常感激!

Figured it out: 弄清楚了:

In the DocumentModelIndex DocType definition: class Meta: index = IndexName . DocumentModelIndex DocType定义中: class Meta: index = IndexName

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

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