gpt4 book ai didi

python - 重新索引elasticsearch api超时,文档大小较大

转载 作者:太空宇宙 更新时间:2023-11-03 20:03:47 30 4
gpt4 key购买 nike

我正在从 python 重新索引一个索引,但文档大小很大(6gig)并且需要 60 分钟,所以我在 api 中超时

代码:

def Reindex(src, dest):
query = {

"source": {
"index": src,
"query": {
"range": {
"UTC_date": {
"lt": "now-15d/d"
}
}
}
},
"dest": {
"index": dest
}
}
Query = {
"query": {
"range": {
"UTC_date": {
"lt": "now-15d/d"
}
}
}
}

try:
result = es.reindex(query, wait_for_completion=True, request_timeout=300)
except:
pass

最佳答案

我找到了解决方案。因为我重新索引 6gig 需要更多时间,所以我增加了超时时间,现在它可以工作了

def Reindex(src, dest):
print("[X] START Reindex")
query = {

"source": {
"index": src,
"query": {
"range": {
"UTC_date": {
"lt": "now-1d/d"
}
}
}
},
"dest": {
"index": dest
}
}
Query = {
"query": {
"range": {
"UTC_date": {
"lt": "now-1d/d"
}
}
}
}

try:
result = es.reindex(query, wait_for_completion=True, request_timeout=10000,conflicts="proceed")
print(result)
log_dict = {}
log_dict['total']=result['total']
log_dict['created']=result['created']
log_dict['updated']=result['updated']
log_dict["Timestamp"] = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
if log_dict['total']==(log_dict['created']+log_dict['updated']):
print("gggggg")
log_dict['status'] = 'success'
Delete(src)
else:
log_dict['status'] = 'failure'
access_logger.info(json.dumps(log_dict))

关于python - 重新索引elasticsearch api超时,文档大小较大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59082686/

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