fix: 识别es版本信息

This commit is contained in:
taojinlong 2021-10-14 11:18:22 +08:00
parent 48fc0234cf
commit 3ad3ff8d50

View File

@ -231,16 +231,17 @@ public class EsProvider extends DatasourceProvider {
throw new Exception(JSONObject.parseObject(response).getJSONObject("error").getString("reason"));
}
String version = JSONObject.parseObject(response).getJSONObject("version").getString("number");
if(Integer.valueOf(version.substring(0,1)) < 6 ){
if(Integer.valueOf(version.split("\\.")[0]) < 6 ){
throw new Exception(Translator.get("i18n_es_limit"));
}
if(Integer.valueOf(version.substring(2,3)) < 3 ){
if(Integer.valueOf(version.split("\\.")[1]) < 3 ){
throw new Exception(Translator.get("i18n_es_limit"));
}
if(Integer.valueOf(version.substring(0,1)) == 6 ) {
if(Integer.valueOf(version.split("\\.")[0]) == 6 ) {
esConfiguration.setUri("_xpack/sql");
}
if(Integer.valueOf(version.substring(0,1)) == 7 ) {
if(Integer.valueOf(version.split("\\.")[0]) == 7 ) {
esConfiguration.setUri("_sql");
}
datasourceRequest.getDatasource().setConfiguration(new Gson().toJson(esConfiguration));