Search in sources :

Example 1 with PutMappingRequestBuilder

use of org.opensearch.action.admin.indices.mapping.put.PutMappingRequestBuilder in project fess by codelibs.

the class UpgradeUtil method putMapping.

public static boolean putMapping(final IndicesAdminClient indicesClient, final String index, final String type, final String source) {
    try {
        final PutMappingRequestBuilder builder = indicesClient.preparePutMapping(index).setSource(source, XContentType.JSON);
        final AcknowledgedResponse pmResponse = builder.execute().actionGet();
        if (pmResponse.isAcknowledged()) {
            return true;
        }
        logger.warn("Failed to update {} settings.", index);
    } catch (final Exception e) {
        logger.warn("Failed to update {} settings.", index, e);
    }
    return false;
}
Also used : PutMappingRequestBuilder(org.opensearch.action.admin.indices.mapping.put.PutMappingRequestBuilder) AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) ResourceNotFoundRuntimeException(org.codelibs.core.exception.ResourceNotFoundRuntimeException)

Aggregations

ResourceNotFoundRuntimeException (org.codelibs.core.exception.ResourceNotFoundRuntimeException)1 PutMappingRequestBuilder (org.opensearch.action.admin.indices.mapping.put.PutMappingRequestBuilder)1 AcknowledgedResponse (org.opensearch.action.support.master.AcknowledgedResponse)1