Skip to content

RolloverRequestBuilder mapping method #37400

@farchanjo

Description

@farchanjo
public RolloverRequestBuilder mapping(String type, String source) {
     this.request.getCreateIndexRequest().mapping(type, source);
     return this;
}

Should be:

public RolloverRequestBuilder mapping(String type, String... source) {
     this.request.getCreateIndexRequest().mapping(type, source);
     return this;
}

Because I'm trying to create a mapping on each Rollover new index, but I'm getting:

mapping source must be pairs of fieldnames and properties definition.

Looking the API I discovered the following issues:
RolloverRequestBuilder.mapping calls:

    public RolloverRequestBuilder mapping(String type, String source) {
        this.request.getCreateIndexRequest().mapping(type, source);
        return this;
    }

but getCreateIndexRequest().mapping has a check:

    public CreateIndexRequest mapping(String type, Object... source) {
        mapping(type, PutMappingRequest.buildFromSimplifiedDef(type, source));
        return this;
    }

and XContentBuilder.buildFromSimplifiedDef validate if source is an even value.

    public static XContentBuilder buildFromSimplifiedDef(String type, Object... source) {
        if (source.length % 2 != 0) {
            throw new IllegalArgumentException("mapping source must be pairs of fieldnames and properties definition.");
        }

if RolloverRequestBuilder mapping(String type, String source) receive only one parameter as a source string, I will always get an error. is that right? Or I'm getting crazy. I have tried to add my mapping on rolling index and I'm always getting an error.

Thanks,
Fabricio

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions