feat: support Elasticsearch datasource #108

This commit is contained in:
junjun
2025-09-16 14:24:29 +08:00
parent ae2b9a2aed
commit bf43221e6a
+3 -1
View File
@@ -5,6 +5,7 @@ import json
import requests
from elasticsearch import Elasticsearch
from fastapi import HTTPException
from apps.datasource.models.datasource import DatasourceConf
@@ -61,7 +62,8 @@ def get_es_fields(conf: DatasourceConf, table_name: str):
def get_es_data(conf: DatasourceConf, sql: str, table_name: str):
r = requests.post(f"{conf.host}/_sql/translate", json={"query": sql})
# print(json.dumps(r.json()))
if r.json().get('error'):
raise HTTPException(status_code=500, detail=f': {json.dumps(r.json())}')
es_client = get_es_connect(conf)
response = es_client.search(