|
|
|
@ -2,10 +2,10 @@ package com.fr.plugin.db.es.fun;
|
|
|
|
|
|
|
|
|
|
import com.fanruan.api.data.open.BaseDataModel; |
|
|
|
|
import com.fanruan.api.err.TableDataException; |
|
|
|
|
import com.fanruan.api.log.LogKit; |
|
|
|
|
import com.fanruan.api.util.StringKit; |
|
|
|
|
import com.fr.json.JSON; |
|
|
|
|
import com.fr.json.JSONFactory; |
|
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
import com.fr.plugin.db.es.fun.assist.SimpleDataModel; |
|
|
|
|
import com.fr.plugin.db.es.fun.category.ResultStandardizeSelector; |
|
|
|
|
import com.fr.plugin.db.es.fun.type.ConverterType; |
|
|
|
@ -16,6 +16,7 @@ import org.elasticsearch.client.Request;
|
|
|
|
|
import org.elasticsearch.client.Response; |
|
|
|
|
import org.elasticsearch.client.RestClient; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@ -68,6 +69,15 @@ public class ElasticsearchDataModel extends BaseDataModel {
|
|
|
|
|
initData(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
throw new TableDataException(e.getMessage(), e); |
|
|
|
|
} finally { |
|
|
|
|
if (client != null) { |
|
|
|
|
try { |
|
|
|
|
client.close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
LogKit.error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
client = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -132,9 +142,6 @@ public class ElasticsearchDataModel extends BaseDataModel {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void release() throws Exception { |
|
|
|
|
if (client != null) { |
|
|
|
|
client.close(); |
|
|
|
|
client = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|