elasticsearch,Python,elasticsearch" /> elasticsearch,Python,elasticsearch" />

如何在python中获得helpers.bulk函数(ElasticSearchAPI)的响应?

如何在python中获得helpers.bulk函数(ElasticSearchAPI)的响应?,python,elasticsearch,Python,elasticsearch,我在上找到了很好的示例,但找不到响应代码。我从中得到的一切 helpers.bulk(es, actions) 是 如所述: 它返回一个元组,其中包含摘要信息—成功执行的操作数以及错误列表或错误数(如果stats_only设置为True) 如果您需要处理大量数据,并且想要忽略/收集错误,请考虑使用SraveGuangBulk()帮助器,它只返回错误,而不将它们存储在内存中。 使用streaming_bulk()时,必须使用raise_on_error参数进行出错时的提升。 如果您想收集大量数据

我在上找到了很好的示例,但找不到响应代码。我从中得到的一切

helpers.bulk(es, actions)

如所述:

它返回一个元组,其中包含摘要信息—成功执行的操作数以及错误列表或错误数(如果stats_only设置为True) 如果您需要处理大量数据,并且想要忽略/收集错误,请考虑使用SraveGuangBulk()帮助器,它只返回错误,而不将它们存储在内存中。 使用streaming_bulk()时,必须使用
raise_on_error
参数进行出错时的提升。
如果您想收集大量数据,我建议使用更快、更直观的方法

我在AWS Lambda上也采用同样的方法将数据推送到ElasticSearch:

print("Pushing data to ES <:", ESindex, ESmapping, ">", helpers.bulk(g.esClient, dataGenerator()))
表示1条记录成功推送到Elasticsearch。如果出现故障,我会得到一个错误日志,如下所示,并且Lambda函数失败。(我已经从Json数据中删除了
[]
数组括号。)


你能给我们展示一下你的完整方法吗?它与表中所示的相同。我期望,
helpers.bulk(es,actions)
返回类似于
Response[200]
{“acknowledged”:true}
的内容。我看到了同样的问题,您是否能够得到响应?如果我们希望得到与从命令行调用bulk API时相同的响应,该怎么办?
print("Pushing data to ES <:", ESindex, ESmapping, ">", helpers.bulk(g.esClient, dataGenerator()))
(1, [])
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