gpt4 book ai didi

python - Elasticsearch-python批量帮助程序API上没有filter_path选项

转载 作者:行者123 更新时间:2023-12-02 22:54:42 24 4
gpt4 key购买 nike

_index _bulk API的响应包含很多信息。该信息对于故障排除请求或实现重试逻辑很有用,但会占用大量带宽。在此示例中,索引32字节的文档将导致339字节的响应(包括标题):

如果我们更新/索引如下文件,

PUT elasticsearch_domain/more-movies/_doc/1
{"title": "Back to the Future"}

它将返回如下响应,
{
"_index": "more-movies",
"_type": "_doc",
"_id": "1",
"_version": 4,
"result": "updated",
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 3,
"_primary_term": 1
}

现在,如果我们在使用 _bulk API的现有索引过程中使用 filter_path
PUT elasticsearch_domain/more-movies/_doc/1?filter_path=result,_shards.total
{"title": "Back to the Future"}

然后响应就像
{
"result": "updated",
"_shards": {
"total": 2
}
}

因此,我的问题是如何使用 filter_path 来过滤 Elasticsearch-python bulk API或流式批量API的响应?

最佳答案

与搜索功能相同。像这样尝试:

elasticsearch.helpers.bulk(client, actions, stats_only=False, filter_path=["hits.hits.result","hits.hits._shards.total"])

关于python - Elasticsearch-python批量帮助程序API上没有filter_path选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59008743/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com