【ES】Python调用Elasticsearch
2022/4/24 1:13:08
本文主要是介绍【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 information - 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.
这篇关于【ES】Python调用Elasticsearch的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python