Search in sources :

Example 1 with ESClient

use of com.alibaba.datax.plugin.writer.elasticsearchwriter.ESClient in project plugins by qlangtech.

the class DataXElasticsearchWriter method initialIndex.

/**
 * 当增量开始执行前,先需要初始化一下索引实例
 *
 * @param esSchema
 */
public void initialIndex(ESTableAlias esSchema) {
    if (esSchema == null) {
        throw new IllegalArgumentException("param esSchema can not be null");
    }
    IHttpToken token = this.getToken();
    /**
     ******************************************************
     * 初始化索引Schema
     ******************************************************
     */
    JSONArray schemaCols = esSchema.getSchemaCols();
    ESClient esClient = new ESClient(ESInitialization.create(token.getEndpoint(), token.getAccessKeyId(), token.getAccessKeySecret(), false, 300000, false, false));
    try {
        esClient.createIndex(this.getIndexName(), this.type, esClient.genMappings(schemaCols, this.type, (columnList) -> {
        }), this.settings, false);
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        try {
            esClient.closeJestClient();
        } catch (Throwable e) {
        }
    }
}
Also used : ISchemaField(com.qlangtech.tis.solrdao.ISchemaField) StringUtils(org.apache.commons.lang.StringUtils) ISchema(com.qlangtech.tis.solrdao.ISchema) ParamsConfig(com.qlangtech.tis.config.ParamsConfig) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) IDataxContext(com.qlangtech.tis.datax.IDataxContext) FormField(com.qlangtech.tis.plugin.annotation.FormField) Context(com.alibaba.citrus.turbine.Context) ESInitialization(com.alibaba.datax.plugin.writer.elasticsearchwriter.ESInitialization) IFieldErrorHandler(com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler) JSONArray(com.alibaba.fastjson.JSONArray) SchemaMetaContent(com.qlangtech.tis.solrdao.SchemaMetaContent) VisualType(com.qlangtech.tis.runtime.module.misc.VisualType) ESTableAlias(com.qlangtech.tis.datax.impl.ESTableAlias) Map(java.util.Map) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) Validator(com.qlangtech.tis.plugin.annotation.Validator) ESFieldType(com.alibaba.datax.plugin.writer.elasticsearchwriter.ESFieldType) TISExtension(com.qlangtech.tis.extension.TISExtension) ESClient(com.alibaba.datax.plugin.writer.elasticsearchwriter.ESClient) ImmutableMap(com.google.common.collect.ImmutableMap) IHttpToken(com.qlangtech.tis.config.aliyun.IHttpToken) DataxWriter(com.qlangtech.tis.datax.impl.DataxWriter) Maps(com.google.common.collect.Maps) Objects(java.util.Objects) Consumer(java.util.function.Consumer) DataXReaderColType(com.qlangtech.tis.plugin.ds.DataXReaderColType) ISearchEngineTypeTransfer(com.qlangtech.tis.datax.ISearchEngineTypeTransfer) JSON(com.alibaba.fastjson.JSON) IOUtils(com.qlangtech.tis.extension.impl.IOUtils) Public(com.qlangtech.tis.annotation.Public) Optional(java.util.Optional) JSONObject(com.alibaba.fastjson.JSONObject) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) IHttpToken(com.qlangtech.tis.config.aliyun.IHttpToken) ESClient(com.alibaba.datax.plugin.writer.elasticsearchwriter.ESClient) JSONArray(com.alibaba.fastjson.JSONArray)

Aggregations

Context (com.alibaba.citrus.turbine.Context)1 ESClient (com.alibaba.datax.plugin.writer.elasticsearchwriter.ESClient)1 ESFieldType (com.alibaba.datax.plugin.writer.elasticsearchwriter.ESFieldType)1 ESInitialization (com.alibaba.datax.plugin.writer.elasticsearchwriter.ESInitialization)1 JSON (com.alibaba.fastjson.JSON)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Maps (com.google.common.collect.Maps)1 Public (com.qlangtech.tis.annotation.Public)1 ParamsConfig (com.qlangtech.tis.config.ParamsConfig)1 IHttpToken (com.qlangtech.tis.config.aliyun.IHttpToken)1 IDataxContext (com.qlangtech.tis.datax.IDataxContext)1 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)1 ISearchEngineTypeTransfer (com.qlangtech.tis.datax.ISearchEngineTypeTransfer)1 DataxWriter (com.qlangtech.tis.datax.impl.DataxWriter)1 ESTableAlias (com.qlangtech.tis.datax.impl.ESTableAlias)1 TISExtension (com.qlangtech.tis.extension.TISExtension)1 IOUtils (com.qlangtech.tis.extension.impl.IOUtils)1 FormField (com.qlangtech.tis.plugin.annotation.FormField)1