简体   繁体   中英

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

I am using elasticsearch 's python client and elasticsearch-dsl as well. I have created an index IndexName and I validated the existence of the index. I have a doc_type DocumentModelIndex associated with this IndexName .

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 .

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.

I am new to elasticsearch and am not able to figure this out. Any help would be much appreciated!

Figured it out:

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

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