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

The following examples show how to use org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction. 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: 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 #2
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 #3
Source File: BaseMetricTransportClient.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
@Override
public BaseMetricTransportClient newMapping(String index, String type, Map<String, Object> mapping) {
    new PutMappingRequestBuilder(client(), PutMappingAction.INSTANCE)
                    .setIndices(index)
                    .setType(type)
                    .setSource(mapping)
                    .execute().actionGet();
    logger.info("mapping created for index {} and type {}", index, type);
    return this;
}
 
Example #4
Source File: BaseClient.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
public void putMapping(String index) {
    if (client() == null) {
        return;
    }
    if (!mappings().isEmpty()) {
        for (Map.Entry<String, String> me : mappings().entrySet()) {
            client().execute(PutMappingAction.INSTANCE,
                    new PutMappingRequest(index).type(me.getKey()).source(me.getValue())).actionGet();
        }
    }
}
 
Example #5
Source File: BulkNodeClient.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
@Override
public BulkNodeClient newMapping(String index, String type, Map<String, Object> mapping) {
    PutMappingRequestBuilder putMappingRequestBuilder =
            new PutMappingRequestBuilder(client(), PutMappingAction.INSTANCE)
                    .setIndices(index)
                    .setType(type)
                    .setSource(mapping);
    putMappingRequestBuilder.execute().actionGet();
    logger.info("mapping created for index {} and type {}", index, type);
    return this;
}
 
Example #6
Source File: HttpBulkNodeClient.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
@Override
public HttpBulkNodeClient newMapping(String index, String type, Map<String, Object> mapping) {
    PutMappingRequestBuilder putMappingRequestBuilder =
            new PutMappingRequestBuilder(client(), PutMappingAction.INSTANCE)
                    .setIndices(index)
                    .setType(type)
                    .setSource(mapping);
    putMappingRequestBuilder.execute().actionGet();
    logger.info("mapping created for index {} and type {}", index, type);
    return this;
}
 
Example #7
Source File: TransportSchemaUpdateAction.java    From crate with Apache License 2.0 5 votes vote down vote up
private CompletableFuture<AcknowledgedResponse> updateMapping(Index index,
                                                              TimeValue timeout,
                                                              String mappingSource) {
    FutureActionListener<AcknowledgedResponse, AcknowledgedResponse> putMappingListener = FutureActionListener.newInstance();
    PutMappingRequest putMappingRequest = new PutMappingRequest()
        .indices(new String[0])
        .setConcreteIndex(index)
        .type(Constants.DEFAULT_MAPPING_TYPE)
        .source(mappingSource, XContentType.JSON)
        .timeout(timeout)
        .masterNodeTimeout(timeout);
    nodeClient.execute(PutMappingAction.INSTANCE, putMappingRequest, putMappingListener);
    return putMappingListener;
}
 
Example #8
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 #9
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void putMapping(final PutMappingRequest request, final ActionListener<PutMappingResponse> listener) {
    execute(PutMappingAction.INSTANCE, request, listener);
}
 
Example #10
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public PutMappingRequestBuilder preparePutMapping(String... indices) {
    return new PutMappingRequestBuilder(this, PutMappingAction.INSTANCE).setIndices(indices);
}
 
Example #11
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<AcknowledgedResponse> putMapping(final PutMappingRequest request) {
    return execute(PutMappingAction.INSTANCE, request);
}
 
Example #12
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void putMapping(final PutMappingRequest request, final ActionListener<AcknowledgedResponse> listener) {
    execute(PutMappingAction.INSTANCE, request, listener);
}
 
Example #13
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public PutMappingRequestBuilder preparePutMapping(String... indices) {
    return new PutMappingRequestBuilder(this, PutMappingAction.INSTANCE).setIndices(indices);
}
 
Example #14
Source File: ActionModule.java    From crate with Apache License 2.0 4 votes vote down vote up
static Map<String, ActionHandler<?, ?>> setupActions(List<ActionPlugin> actionPlugins) {
    // Subclass NamedRegistry for easy registration
    class ActionRegistry extends NamedRegistry<ActionHandler<?, ?>> {
        ActionRegistry() {
            super("action");
        }

        public void register(ActionHandler<?, ?> handler) {
            register(handler.getAction().name(), handler);
        }

        public <Request extends TransportRequest, Response extends TransportResponse> void register(
                GenericAction<Request, Response> action, Class<? extends TransportAction<Request, Response>> transportAction,
                Class<?>... supportTransportActions) {
            register(new ActionHandler<>(action, transportAction, supportTransportActions));
        }
    }

    ActionRegistry actions = new ActionRegistry();
    actions.register(ClusterStateAction.INSTANCE, TransportClusterStateAction.class);
    actions.register(ClusterHealthAction.INSTANCE, TransportClusterHealthAction.class);
    actions.register(ClusterUpdateSettingsAction.INSTANCE, TransportClusterUpdateSettingsAction.class);
    actions.register(ClusterRerouteAction.INSTANCE, TransportClusterRerouteAction.class);
    actions.register(PendingClusterTasksAction.INSTANCE, TransportPendingClusterTasksAction.class);
    actions.register(PutRepositoryAction.INSTANCE, TransportPutRepositoryAction.class);
    actions.register(DeleteRepositoryAction.INSTANCE, TransportDeleteRepositoryAction.class);
    actions.register(GetSnapshotsAction.INSTANCE, TransportGetSnapshotsAction.class);
    actions.register(DeleteSnapshotAction.INSTANCE, TransportDeleteSnapshotAction.class);
    actions.register(CreateSnapshotAction.INSTANCE, TransportCreateSnapshotAction.class);
    actions.register(RestoreSnapshotAction.INSTANCE, TransportRestoreSnapshotAction.class);
    actions.register(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class);
    actions.register(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class);
    actions.register(ResizeAction.INSTANCE, TransportResizeAction.class);
    actions.register(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class);
    actions.register(PutMappingAction.INSTANCE, TransportPutMappingAction.class);
    actions.register(UpdateSettingsAction.INSTANCE, TransportUpdateSettingsAction.class);
    actions.register(PutIndexTemplateAction.INSTANCE, TransportPutIndexTemplateAction.class);
    actions.register(GetIndexTemplatesAction.INSTANCE, TransportGetIndexTemplatesAction.class);
    actions.register(DeleteIndexTemplateAction.INSTANCE, TransportDeleteIndexTemplateAction.class);
    actions.register(RefreshAction.INSTANCE, TransportRefreshAction.class);
    actions.register(SyncedFlushAction.INSTANCE, TransportSyncedFlushAction.class);
    actions.register(ForceMergeAction.INSTANCE, TransportForceMergeAction.class);
    actions.register(UpgradeAction.INSTANCE, TransportUpgradeAction.class);
    actions.register(UpgradeSettingsAction.INSTANCE, TransportUpgradeSettingsAction.class);
    actions.register(RecoveryAction.INSTANCE, TransportRecoveryAction.class);
    actions.register(AddVotingConfigExclusionsAction.INSTANCE, TransportAddVotingConfigExclusionsAction.class);
    actions.register(ClearVotingConfigExclusionsAction.INSTANCE, TransportClearVotingConfigExclusionsAction.class);
    actions.register(NodesStatsAction.INSTANCE, TransportNodesStatsAction.class);

    actionPlugins.stream().flatMap(p -> p.getActions().stream()).forEach(actions::register);

    return unmodifiableMap(actions.getRegistry());
}