fix: 在 bd2gaode.py 中增加 hasattr 校验,兼容低版本 elasticsearch 客户端,防止 options() 报错

This commit is contained in:
王文艳
2026-08-17 12:29:33 +08:00
parent bf2923bdc4
commit 5603858a93
+1
View File
@@ -13,6 +13,7 @@ import logging
log = logging.getLogger(__name__)
# 🛡️ 2. 终极绝招:利用 Elasticsearch 8.x 官方 options() 机制,强行生成一个无 compatible 请求头的底层客户端并覆盖,彻底降维打击 406 报错!
if hasattr(DIDATA_DEV_ELASTIC_CLIENT.elastic_client, 'options'):
DIDATA_DEV_ELASTIC_CLIENT.elastic_client = DIDATA_DEV_ELASTIC_CLIENT.elastic_client.options(
headers={"content-type": "application/json", "accept": "application/json"}
)