问题
查询Es报错:This limit can be set by changing the [index.max_result_window] index level
Es默认查询条目数量是10000条,超过了就需要单独设置最大查询条目数了;
解决
# 查询的数量用page*page_size表示,严格的来说是(page-1)*pang_size
if page *page_size >= 10000:
# 超过 默认的100000 条就要更新的设置
settings = {
"index": {
"max_result_window": "2000000"
}
}
try:
response = es.indices.put_settings(index=index_name, body=settings, preserve_existing=True)
print("Settings updated successfully:", response)
except Exception as e:
print("Error updating settings:", e)