微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

【ES】Python调用Elasticsearch

高版本问题

The client noticed that the server is not a supported distribution of Elasticsearch

尽量使用 elasticsearch==7.13.4

https://blog.csdn.net/songkai558919/article/details/119568829

https://blog.csdn.net/alex_xfboy/article/details/86100037

参考:https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.bulk

def gendata():
    mywords = ['foo', 'bar', 'baz']
    for word in mywords:
        yield {
            "_index": "mywords",
            "_type": "document",
            "doc": {"word": word},
        }

res_tuple = helpers.bulk(es, gendata())
res_tuple

Helper for the bulk() api that provides a more human friendly interface - it consumes an iterator of actions and sends them to elasticsearch in chunks. It returns a tuple with summary @R_658_4045@ion - number of successfully executed actions and either list of errors or number of errors if stats_only is set to True. Note that by default we raise a BulkIndexError when we encounter an error so options like stats_only only apply when raise_on_error is set to False.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐