![](/img/trans.png)
[英]Python elasticsearch helpers.bulk erroneously fails? (script or doc is missing)
[英]How can I get in python response for helpers.bulk function (elasticsearch API)?
如文档中所写:
它返回一个带有摘要信息的元组-成功执行的操作数以及错误列表或错误数(如果stats_only设置为True [...])如果您需要处理大量数据并想要忽略/收集错误,请...考虑使用streaming_bulk()帮助器,该帮助器将仅返回错误而不将其存储在内存中。
对于streaming_bulk(),必须使用raise_on_error
参数来引发错误。 如果您想收集很多数据,我建议使用parallel_bulk() ,它更快,更直观
我在AWS Lambda上以相同的方式将数据推送到ElasticSearch:
print("Pushing data to ES <:", ESindex, ESmapping, ">", helpers.bulk(g.esClient, dataGenerator()))
这里的回应
(1, [])
表示1条记录已成功推送到Elasticsearch。 万一发生故障,我会收到如下所示的错误日志 ,并且Lambda函数失败。 ( 我从Json数据中删除了[]
数组括号。 )
RequestError(400, 'action_request_validation_exception', 'Validation Failed: 1: index is missing;2: type is missing;3: index is missing;4: type is missing;5: index is missing;6: type is missing;7: index is missing;8: type is missing;9: index is missing;10: type is missing;11: index is missing;12: type is missing;13: index is missing;14: type is missing;15: index is missing;16: type is missing;17: index is missing;18: type is missing;19: index is missing;20: type is missing;21: index is missing;22: type is missing;23: index is missing;24: type is missing;25: index is missing;26: type is missing;27: index is missing;28: type is missing;29: index is missing;30: type is missing;'): RequestError
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.