简体   繁体   中英

Elasticsearch python library "post" a document

I'm using Elasticsearch python library. The method create require an ID to index a document.

I cannot find in the documentation a method to "post" a document into an index. By post I mean a method that will take in charge the generation of the ID for me.

Is there any way to let ES generate the ID for me or do I have to generate a random ID by myself and use the create method?

By default, ES will auto-generate an ID for you if you don't provide one.

Since you're using the ES Python library you can leverage the index() function and not provide any ID, ES will generate one for you.

client.index(index='my_index', body=mydoc)

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