fix: es 数据源添加表

This commit is contained in:
taojinlong 2022-04-05 21:57:43 +08:00
parent 8ec3e7f837
commit fbb2651832

View File

@ -13,6 +13,7 @@ import io.dataease.dto.datasource.TableDesc;
import io.dataease.dto.datasource.TableField;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator;
import io.dataease.plugins.common.constants.EsSqlLConstants;
import io.dataease.provider.query.es.EsQueryProvider;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
@ -97,7 +98,7 @@ public class EsProvider extends DatasourceProvider {
@Override
public List<TableField> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
datasourceRequest.setQuery("desc " + datasourceRequest.getTable());
datasourceRequest.setQuery("desc " + String.format(EsSqlLConstants.KEYWORD_TABLE, datasourceRequest.getTable()));
List<TableField> tableFields = new ArrayList<>();
try {
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
@ -292,6 +293,7 @@ public class EsProvider extends DatasourceProvider {
Request request = new Request();
request.setQuery(sql);
request.setFetch_size(datasourceRequest.getFetchSize());
System.out.println(new Gson().toJson(request));
String url = esConfiguration.getUrl().endsWith("/") ? esConfiguration.getUrl() + uri : esConfiguration.getUrl() + "/" + uri;
String response = HttpClientUtil.post(url, new Gson().toJson(request), httpClientConfig);
return response;