RollOver API - Add Mapping

Hi everyone,

I'm trying to create a service to rollover an index to me, but before to rollover I have to copy my setting and mapping to add a new index to be created.

I'm getting a primary mapping:

GetMappingsResponse response = client.admin()


        .forEach(objectCursor -> {
            try {
                        .forEach(entry -> {
                            builder.mapping(objectCursor.value.type(), String.valueOf(entry.getValue()));
            } catch (Exception e) {
                logger.warn("addMapping", e);

This is my Request RollOver builder:

RolloverRequestBuilder builder = client.admin().indices()
.addMaxIndexSizeCondition(new ByteSizeValue(roll.getSize(),

I know its a wrong way, but rollover builder api only accept (String type, String source), how can I convert it to (String type, String source) ?

I have tried too many things and always getting.

mapping source must be pairs of fieldnames and properties definition


I would recommend applying mappings through an index template instead. That way it will automatically be applied when rollover generates a new index. This is shown in this blog post.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.