org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse Java Examples

The following examples show how to use org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MappingUpdatedAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public void updateMappingOnMaster(String index, String type, Mapping mappingUpdate, final TimeValue timeout, final MappingUpdateListener listener) {
    final PutMappingRequestBuilder request = updateMappingRequest(index, type, mappingUpdate, timeout);
    if (listener == null) {
        request.execute();
    } else {
        final ActionListener<PutMappingResponse> actionListener = new ActionListener<PutMappingResponse>() {
            @Override
            public void onResponse(PutMappingResponse response) {
                if (response.isAcknowledged()) {
                    listener.onMappingUpdate();
                } else {
                    listener.onFailure(new TimeoutException("Failed to acknowledge the mapping response within [" + timeout + "]"));
                }
            }

            @Override
            public void onFailure(Throwable e) {
                listener.onFailure(e);
            }
        };
        request.execute(actionListener);
    }
}
 
Example #2
Source File: AbstractEsTest.java    From test-data-generator with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    if (client.admin().indices().prepareExists(getIndexName()).execute().actionGet().isExists()) {
        DeleteIndexResponse deleteIndexResponse = client.admin().indices().prepareDelete(getIndexName())
                .execute().actionGet();
        Assert.assertTrue(deleteIndexResponse.isAcknowledged());
    }
    CreateIndexResponse createIndexResponse = client.admin().indices().prepareCreate(getIndexName())
            .execute().actionGet();
    Assert.assertTrue(createIndexResponse.isAcknowledged());
    for (Map.Entry<String, String> esMapping : getEsMappings().entrySet()) {
        String esMappingSource = IOUtils.toString(
                AbstractEsTest.class.getClassLoader().getResourceAsStream(esMapping.getValue()));
        PutMappingResponse putMappingResponse = client.admin().indices().preparePutMapping(getIndexName())
                .setType(esMapping.getKey()).setSource(esMappingSource).execute().actionGet();
        Assert.assertTrue(putMappingResponse.isAcknowledged());
    }
}
 
Example #3
Source File: ElasticSearchUtils.java    From ElasticUtils with MIT License 6 votes vote down vote up
private static PutMappingResponse internalPutMapping(Client client, String indexName, IElasticSearchMapping mapping) throws IOException {

        final PutMappingRequest putMappingRequest = new PutMappingRequest(indexName)
                .type(mapping.getIndexType())
                .source(mapping.getMapping().string());

        final PutMappingResponse putMappingResponse = client
                .admin()
                .indices()
                .putMapping(putMappingRequest)
                .actionGet();

        if(log.isDebugEnabled()) {
            log.debug("PutMappingResponse: isAcknowledged {}", putMappingResponse.isAcknowledged());
        }

        return putMappingResponse;
    }
 
Example #4
Source File: ElasticSearchUtils.java    From ElasticUtils with MIT License 6 votes vote down vote up
private static PutMappingResponse internalPutMapping(Client client, String indexName, IElasticSearchMapping mapping) throws IOException {

        final PutMappingRequest putMappingRequest = new PutMappingRequest(indexName)
                .type(mapping.getIndexType())
                .source(mapping.getMapping().string());

        final PutMappingResponse putMappingResponse = client
                .admin()
                .indices()
                .putMapping(putMappingRequest)
                .actionGet();

        if(log.isDebugEnabled()) {
            log.debug("PutMappingResponse: isAcknowledged {}", putMappingResponse.isAcknowledged());
        }

        return putMappingResponse;
    }
 
Example #5
Source File: DefaultElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 6 votes vote down vote up
@Override
public void putMapping(List<String> indices, String type, JsonObject source, MappingOptions options, Handler<AsyncResult<Void>> resultHandler) {

    final PutMappingRequestBuilder builder = PutMappingAction.INSTANCE.newRequestBuilder(service.getClient())
            .setIndices(indices.toArray(new String[indices.size()]))
            .setType(type)
            .setSource(source.encode(), XContentType.JSON);

    builder.execute(new ActionListener<PutMappingResponse>() {
        @Override
        public void onResponse(PutMappingResponse putMappingResponse) {
            resultHandler.handle(Future.succeededFuture());
        }

        @Override
        public void onFailure(Exception e) {
            resultHandler.handle(Future.failedFuture(e));
        }
    });
}
 
Example #6
Source File: ElasticsearchUtil.java    From SpringBootLearn with Apache License 2.0 5 votes vote down vote up
/**
 * 创建索引以及映射mapping,并给索引某些字段指定iK分词,以后向该索引中查询时,就会用ik分词。
 * @Author lihaodong
 * @Description
 * @Date 20:19 2018/12/21
 * @Param [indexName, esType]
 * @return boolean
 **/
public static boolean createIndex(String indexName, String esType) {
    if (!isIndexExist(indexName)) {
        log.info("Index is not exits!");
    }
    //创建映射
    XContentBuilder mapping = null;
    try {
        mapping = XContentFactory.jsonBuilder()
                .startObject()
                .startObject("properties") //      .startObject("m_id").field("type","keyword").endObject()
                // title:字段名,  type:文本类型       analyzer :分词器类型
                .startObject("id").field("type", "text").field("analyzer", "standard").endObject()   //该字段添加的内容,查询时将会使用ik_smart分词
                .startObject("name").field("type", "text").field("analyzer", "standard").endObject()  //ik_smart  ik_max_word  standard
                .startObject("message").field("type", "text").field("analyzer", "standard").endObject()
                .startObject("price").field("type", "float").endObject()
                .startObject("creatDate").field("type", "date").endObject()
                .endObject()
                .endObject();
    } catch (IOException e) {
        log.error("执行建立失败:{}",e.getMessage());
    }
    //index:索引名   type:类型名
    PutMappingRequest putmap = Requests.putMappingRequest(indexName).type(esType).source(mapping);
    //创建索引
    client.admin().indices().prepareCreate(indexName).execute().actionGet();
    //为索引添加映射
    PutMappingResponse indexresponse = client.admin().indices().putMapping(putmap).actionGet();
    log.info("执行建立成功?" + indexresponse.isAcknowledged());
    return indexresponse.isAcknowledged();
}
 
Example #7
Source File: InternalEsClient.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * Mapping定義を更新する.
 * @param index インデックス名
 * @param type タイプ名
 * @param mappings マッピング情報
 * @return 非同期応答
 */
public ListenableActionFuture<PutMappingResponse> putMapping(String index,
        String type,
        Map<String, Object> mappings) {
    PutMappingRequestBuilder builder = new PutMappingRequestBuilder(esTransportClient.admin().indices())
            .setIndices(index)
            .setType(type)
            .setSource(mappings);
    return builder.execute();
}
 
Example #8
Source File: DcPutMappingResponseImpl.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * .
 * @param response .
 * @return .
 */
public static DcPutMappingResponse getInstance(PutMappingResponse response) {
    if (response == null) {
        return null;
    }
    return new DcPutMappingResponseImpl(response);
}
 
Example #9
Source File: EsTypeImpl.java    From io with Apache License 2.0 5 votes vote down vote up
@Override
PutMappingResponse onParticularError(ElasticsearchException e) {
    if (e instanceof IndexMissingException || e.getCause() instanceof IndexMissingException) {
        throw new EsClientException.EsIndexMissingException(e);
    }
    if (e instanceof MapperParsingException) {
        throw new EsClientException.EsSchemaMismatchException(e);
    }
    throw e;
}
 
Example #10
Source File: AbstractWriter.java    From elasticsearch-taste with Apache License 2.0 5 votes vote down vote up
public void open() {
    final IndicesExistsResponse existsResponse = client.admin().indices()
            .prepareExists(index).execute().actionGet();
    if (!existsResponse.isExists()) {
        final CreateIndexResponse createIndexResponse = client.admin()
                .indices().prepareCreate(index).execute().actionGet();
        if (!createIndexResponse.isAcknowledged()) {
            throw new TasteException("Failed to create " + index
                    + " index.");
        }
    }

    if (mappingBuilder != null) {
        final GetMappingsResponse response = client.admin().indices()
                .prepareGetMappings(index).setTypes(type).execute()
                .actionGet();
        if (response.mappings().isEmpty()) {
            final PutMappingResponse putMappingResponse = client.admin()
                    .indices().preparePutMapping(index).setType(type)
                    .setSource(mappingBuilder).execute().actionGet();
            if (!putMappingResponse.isAcknowledged()) {
                throw new TasteException("Failed to create a mapping of"
                        + index + "/" + type);
            }
        }
    }
}
 
Example #11
Source File: EsTypeImpl.java    From io with Apache License 2.0 5 votes vote down vote up
@Override
PutMappingResponse onParticularError(ElasticsearchException e) {
    if (e instanceof IndexNotFoundException || e.getCause() instanceof IndexNotFoundException) {
        throw new EsClientException.EsIndexMissingException(e);
    }
    if (e instanceof MapperParsingException) {
        throw new EsClientException.EsSchemaMismatchException(e);
    }
    throw e;
}
 
Example #12
Source File: InternalEsClient.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * Mapping定義を更新する.
 * @param index インデックス名
 * @param type タイプ名
 * @param mappings マッピング情報
 * @return 非同期応答
 */
public ListenableActionFuture<PutMappingResponse> putMapping(String index,
        String type,
        Map<String, Object> mappings) {
    PutMappingRequestBuilder builder = new PutMappingRequestBuilder(esTransportClient.admin().indices(), PutMappingAction.INSTANCE)
            .setIndices(index)
            .setType(type)
            .setSource(mappings);
    return builder.execute();
}
 
Example #13
Source File: DcPutMappingResponseImpl.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * .
 * @param response .
 * @return .
 */
public static DcPutMappingResponse getInstance(PutMappingResponse response) {
    if (response == null) {
        return null;
    }
    return new DcPutMappingResponseImpl(response);
}
 
Example #14
Source File: ElasticsearchClient.java    From hawkular-apm with Apache License 2.0 5 votes vote down vote up
/**
 * This method applies the supplied mapping to the index.
 *
 * @param index The name of the index
 * @param defaultMappings The default mappings
 * @return true if the mapping was successful
 */
@SuppressWarnings("unchecked")
private boolean prepareMapping(String index, Map<String, Object> defaultMappings) {
    boolean success = true;

    for (Map.Entry<String, Object> stringObjectEntry : defaultMappings.entrySet()) {
        Map<String, Object> mapping = (Map<String, Object>) stringObjectEntry.getValue();
        if (mapping == null) {
            throw new RuntimeException("type mapping not defined");
        }
        PutMappingRequestBuilder putMappingRequestBuilder = client.admin().indices().preparePutMapping()
                .setIndices(index);
        putMappingRequestBuilder.setType(stringObjectEntry.getKey());
        putMappingRequestBuilder.setSource(mapping);

        if (log.isLoggable(Level.FINE)) {
            log.fine("Elasticsearch create mapping for index '"
                    + index + " and type '" + stringObjectEntry.getKey() + "': " + mapping);
        }

        PutMappingResponse resp = putMappingRequestBuilder.execute().actionGet();

        if (resp.isAcknowledged()) {
            if (log.isLoggable(Level.FINE)) {
                log.fine("Elasticsearch mapping for index '"
                        + index + " and type '" + stringObjectEntry.getKey() + "' was acknowledged");
            }
        } else {
            success = false;
            log.warning("Elasticsearch mapping creation was not acknowledged for index '"
                    + index + " and type '" + stringObjectEntry.getKey() + "'");
        }
    }

    return success;
}
 
Example #15
Source File: CrudDemo.java    From javabase with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param indicesAdminClient
 * @param indexName
 * @param typeName
 * @throws IOException
 */
private static void indexMapping(IndicesAdminClient indicesAdminClient, String indexName, String typeName) throws IOException {
    //type就相当于表的
    String typeSource=getIndexTypeSource(typeName,FIELD_NAME);
    //typetwo
    PutMappingRequest mapping = Requests.putMappingRequest(indexName).type(typeName).source("typeSource");

    PutMappingResponse putMappingResponseTwo = indicesAdminClient.putMapping(mapping).actionGet();
}
 
Example #16
Source File: PutMappingRequestBuilder.java    From elasticshell with Apache License 2.0 5 votes vote down vote up
@Override
protected XContentBuilder toXContent(PutMappingRequest request, PutMappingResponse response, XContentBuilder builder) throws IOException {
    builder.startObject()
            .field(Fields.OK, true)
            .field(Fields.ACKNOWLEDGED, response.isAcknowledged());
    builder.endObject();
    return builder;
}
 
Example #17
Source File: ElasticSearchUtils.java    From ElasticUtils with MIT License 5 votes vote down vote up
public static PutMappingResponse putMapping(Client client, String indexName, IElasticSearchMapping mapping) {
    try {
        return internalPutMapping(client, indexName, mapping);
    } catch(Exception e) {
        if(log.isErrorEnabled()) {
            log.error("Error Creating Index", e);
        }
        throw new PutMappingFailedException(indexName, e);
    }
}
 
Example #18
Source File: ElasticSearchUtils.java    From ElasticUtils with MIT License 5 votes vote down vote up
public static PutMappingResponse putMapping(Client client, String indexName, IElasticSearchMapping mapping) {
    try {
        return internalPutMapping(client, indexName, mapping);
    } catch(Exception e) {
        if(log.isErrorEnabled()) {
            log.error("Error Creating Index", e);
        }
        throw new PutMappingFailedException(indexName, e);
    }
}
 
Example #19
Source File: EsIndexMappingMigrationPlugin.java    From usergrid with Apache License 2.0 5 votes vote down vote up
/**
 * Setup ElasticSearch type mappings as a template that applies to all new indexes.
 * Applies to all indexes that* start with our prefix.
 */
private void createMappings(final String indexName)  {

    //Added For Graphite Metrics
    PutMappingResponse pitr = provider.getClient().admin().indices().preparePutMapping( indexName ).setType( "entity" ).setSource(
        getMappingsContent() ).execute().actionGet();
    if ( !pitr.isAcknowledged() ) {
        throw new RuntimeException( "Unable to create default mappings" );
    }
}
 
Example #20
Source File: RestPutMappingAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index")));
    putMappingRequest.type(request.param("type"));
    putMappingRequest.source(request.content().toUtf8());
    putMappingRequest.updateAllTypes(request.paramAsBoolean("update_all_types", false));
    putMappingRequest.reindex(request.paramAsBoolean("reindex", false));
    putMappingRequest.timeout(request.paramAsTime("timeout", putMappingRequest.timeout()));
    putMappingRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putMappingRequest.masterNodeTimeout()));
    putMappingRequest.indicesOptions(IndicesOptions.fromRequest(request, putMappingRequest.indicesOptions()));
    client.admin().indices().putMapping(putMappingRequest, new AcknowledgedRestListener<PutMappingResponse>(channel));
}
 
Example #21
Source File: EsEntityIndexImpl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
/**
 * Setup ElasticSearch type mappings as a template that applies to all new indexes.
 * Applies to all indexes that* start with our prefix.
 */
private void createMappings(final String indexName) throws IOException {


    //Added For Graphite Metrics
    Timer.Context timePutIndex = mappingTimer.time();
    PutMappingResponse  pitr = esProvider.getClient().admin().indices().preparePutMapping( indexName ).setType( "entity" ).setSource(
        getMappingsContent() ).execute().actionGet();
    timePutIndex.stop();
    if ( !pitr.isAcknowledged() ) {
        throw new IndexException( "Unable to create default mappings" );
    }
}
 
Example #22
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<PutMappingResponse> putMapping(final PutMappingRequest request) {
    return execute(PutMappingAction.INSTANCE, request);
}
 
Example #23
Source File: PutMappingRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected ActionFuture<PutMappingResponse> doExecute(PutMappingRequest request) {
    return client.admin().indices().putMapping(request);
}
 
Example #24
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public ListenableActionFuture<PutMappingResponse> putMapping(String index,
        String type, Map<String, Object> mappings) {
    throwException();
    return super.putMapping(index, type, mappings);
}
 
Example #25
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public ListenableActionFuture<PutMappingResponse> putMapping(String index,
        String type, Map<String, Object> mappings) {
    throwException();
    return super.putMapping(index, type, mappings);
}
 
Example #26
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public ListenableActionFuture<PutMappingResponse> putMapping(String index,
        String type, Map<String, Object> mappings) {
    throwException();
    return super.putMapping(index, type, mappings);
}
 
Example #27
Source File: EsRetryTest.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
public ListenableActionFuture<PutMappingResponse> putMapping(String index,
        String type, Map<String, Object> mappings) {
    throwException();
    return super.putMapping(index, type, mappings);
}
 
Example #28
Source File: ItemRequestHandler.java    From elasticsearch-taste with Apache License 2.0 4 votes vote down vote up
private void doItemMappingCreation(final Params params,
        final RequestHandler.OnErrorListener listener,
        final Map<String, Object> requestMap,
        final Map<String, Object> paramMap, final RequestHandlerChain chain) {
    final String index = params.param(
            TasteConstants.REQUEST_PARAM_ITEM_INDEX, params.param("index"));
    final String type = params.param(
            TasteConstants.REQUEST_PARAM_ITEM_TYPE,
            TasteConstants.ITEM_TYPE);
    final String itemIdField = params.param(
            TasteConstants.REQUEST_PARAM_ITEM_ID_FIELD,
            TasteConstants.ITEM_ID_FIELD);
    final String timestampField = params.param(
            TasteConstants.REQUEST_PARAM_TIMESTAMP_FIELD,
            TasteConstants.TIMESTAMP_FIELD);

    try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
        final ClusterHealthResponse healthResponse = client
                .admin()
                .cluster()
                .prepareHealth(index)
                .setWaitForYellowStatus()
                .setTimeout(
                        params.param("timeout",
                                DEFAULT_HEALTH_REQUEST_TIMEOUT)).execute()
                .actionGet();
        if (healthResponse.isTimedOut()) {
            listener.onError(new OperationFailedException(
                    "Failed to create index: " + index + "/" + type));
        }

        final XContentBuilder builder = jsonBuilder//
                .startObject()//
                .startObject(type)//
                .startObject("properties")//

                // @timestamp
                .startObject(timestampField)//
                .field("type", "date")//
                .field("format", "date_optional_time")//
                .endObject()//

                // item_id
                .startObject(itemIdField)//
                .field("type", "long")//
                .endObject()//

                // system_id
                .startObject("system_id")//
                .field("type", "string")//
                .field("index", "not_analyzed")//
                .endObject()//

                .endObject()//
                .endObject()//
                .endObject();

        final PutMappingResponse mappingResponse = client.admin().indices()
                .preparePutMapping(index).setType(type).setSource(builder)
                .execute().actionGet();
        if (mappingResponse.isAcknowledged()) {
            fork(() -> execute(params, listener, requestMap, paramMap,
                    chain));
        } else {
            listener.onError(new OperationFailedException(
                    "Failed to create mapping for " + index + "/" + type));
        }
    } catch (final Exception e) {
        listener.onError(e);
    }
}
 
Example #29
Source File: S3River.java    From es-amazon-s3-river with Apache License 2.0 4 votes vote down vote up
private void pushMapping(String index, String type, XContentBuilder xcontent) throws Exception {
   if (logger.isTraceEnabled()){
      logger.trace("pushMapping(" + index + ", " + type + ")");
   }

   // If type does not exist, we create it
   boolean mappingExist = isMappingExist(index, type);
   if (!mappingExist) {
      logger.debug("Mapping [" + index + "]/[" + type + "] doesn't exist. Creating it.");

      // Read the mapping json file if exists and use it.
      if (xcontent != null){
         if (logger.isTraceEnabled()){
            logger.trace("Mapping for [" + index + "]/[" + type + "]=" + xcontent.string());
         }
         // Create type and mapping
         PutMappingResponse response = client.admin().indices()
               .preparePutMapping(index)
               .setType(type)
               .setSource(xcontent)
               .execute().actionGet();       
         if (!response.isAcknowledged()){
            throw new Exception("Could not define mapping for type [" + index + "]/[" + type + "].");
         } else {
            if (logger.isDebugEnabled()){
               if (mappingExist){
                  logger.debug("Mapping definition for [" + index + "]/[" + type + "] succesfully merged.");
               } else {
                  logger.debug("Mapping definition for [" + index + "]/[" + type + "] succesfully created.");
               }
            }
         }
      } else {
         if (logger.isDebugEnabled()){
            logger.debug("No mapping definition for [" + index + "]/[" + type + "]. Ignoring.");
         }
      }
   } else {
      if (logger.isDebugEnabled()){
         logger.debug("Mapping [" + index + "]/[" + type + "] already exists and mergeMapping is not set.");
      }
   }
   if (logger.isTraceEnabled()){
      logger.trace("/pushMapping(" + index + ", " + type + ")");
   }
}
 
Example #30
Source File: PreferenceRequestHandler.java    From elasticsearch-taste with Apache License 2.0 4 votes vote down vote up
private void doPreferenceMappingCreation(final Params params,
        final RequestHandler.OnErrorListener listener,
        final Map<String, Object> requestMap,
        final Map<String, Object> paramMap, final RequestHandlerChain chain) {
    final String index = params.param("index");
    final String type = params
            .param("type", TasteConstants.PREFERENCE_TYPE);
    final String userIdField = params.param(
            TasteConstants.REQUEST_PARAM_USER_ID_FIELD,
            TasteConstants.USER_ID_FIELD);
    final String itemIdField = params.param(
            TasteConstants.REQUEST_PARAM_ITEM_ID_FIELD,
            TasteConstants.ITEM_ID_FIELD);
    final String valueField = params.param(
            TasteConstants.REQUEST_PARAM_VALUE_FIELD,
            TasteConstants.VALUE_FIELD);
    final String timestampField = params.param(
            TasteConstants.REQUEST_PARAM_TIMESTAMP_FIELD,
            TasteConstants.TIMESTAMP_FIELD);

    try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
        final ClusterHealthResponse healthResponse = client
                .admin()
                .cluster()
                .prepareHealth(index)
                .setWaitForYellowStatus()
                .setTimeout(
                        params.param("timeout",
                                DEFAULT_HEALTH_REQUEST_TIMEOUT)).execute()
                .actionGet();
        if (healthResponse.isTimedOut()) {
            listener.onError(new OperationFailedException(
                    "Failed to create index: " + index + "/" + type));
        }

        final XContentBuilder builder = jsonBuilder//
                .startObject()//
                .startObject(type)//
                .startObject("properties")//

                // @timestamp
                .startObject(timestampField)//
                .field("type", "date")//
                .field("format", "date_optional_time")//
                .endObject()//

                // user_id
                .startObject(userIdField)//
                .field("type", "long")//
                .endObject()//

                // item_id
                .startObject(itemIdField)//
                .field("type", "long")//
                .endObject()//

                // value
                .startObject(valueField)//
                .field("type", "double")//
                .endObject()//

                .endObject()//
                .endObject()//
                .endObject();

        final PutMappingResponse mappingResponse = client.admin().indices()
                .preparePutMapping(index).setType(type).setSource(builder)
                .execute().actionGet();
        if (mappingResponse.isAcknowledged()) {
            fork(() -> execute(params, listener, requestMap, paramMap,
                    chain));
        } else {
            listener.onError(new OperationFailedException(
                    "Failed to create mapping for " + index + "/" + type));
        }
    } catch (final Exception e) {
        listener.onError(e);
    }
}