Skip to content

Commit bf43221

Browse files
committed
feat: support Elasticsearch datasource #108
1 parent ae2b9a2 commit bf43221

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

backend/apps/db/es_engine.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import requests
77
from elasticsearch import Elasticsearch
8+
from fastapi import HTTPException
89

910
from apps.datasource.models.datasource import DatasourceConf
1011

@@ -61,7 +62,8 @@ def get_es_fields(conf: DatasourceConf, table_name: str):
6162

6263
def get_es_data(conf: DatasourceConf, sql: str, table_name: str):
6364
r = requests.post(f"{conf.host}/_sql/translate", json={"query": sql})
64-
# print(json.dumps(r.json()))
65+
if r.json().get('error'):
66+
raise HTTPException(status_code=500, detail=f': {json.dumps(r.json())}')
6567

6668
es_client = get_es_connect(conf)
6769
response = es_client.search(

0 commit comments

Comments
 (0)