Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.elasticsearch.index.mapper.size;

import org.elasticsearch.common.Explicit;
import org.elasticsearch.index.mapper.ContentPath;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MetadataFieldMapper;
Expand Down Expand Up @@ -53,7 +52,7 @@ protected List<Parameter<?>> getParameters() {
}

@Override
public SizeFieldMapper build(ContentPath contentPath) {
public SizeFieldMapper build() {
return new SizeFieldMapper(enabled.getValue(), new NumberFieldType(NAME, NumberType.INTEGER));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public void testHighlightingOnCustomString() throws Exception {
public void testExternalValues() throws Exception {
prepareCreate("test-idx").setMapping(
XContentFactory.jsonBuilder().startObject().startObject("_doc")
.startObject(ExternalMetadataMapper.CONTENT_TYPE)
.endObject()
.startObject("properties")
.startObject("field").field("type", ExternalMapperPlugin.EXTERNAL).endObject()
.endObject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,14 @@

import java.io.IOException;
import java.util.Collections;
import java.util.List;

/** Mapper for the doc_count field. */
public class DocCountFieldMapper extends MetadataFieldMapper {

public static final String NAME = "_doc_count";
public static final String CONTENT_TYPE = "_doc_count";

public static final TypeParser PARSER = new ConfigurableTypeParser(
c -> new DocCountFieldMapper(),
c -> new DocCountFieldMapper.Builder());

static class Builder extends MetadataFieldMapper.Builder {

Builder() {
super(NAME);
}

@Override
protected List<Parameter<?>> getParameters() {
return Collections.emptyList();
}

@Override
public DocCountFieldMapper build(ContentPath contentPath) {
return new DocCountFieldMapper();
}
}
public static final TypeParser PARSER = new FixedTypeParser(c -> new DocCountFieldMapper());

public static final class DocCountFieldType extends MappedFieldType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected List<Parameter<?>> getParameters() {
}

@Override
public FieldNamesFieldMapper build(ContentPath contentPath) {
public FieldNamesFieldMapper build() {
if (enabled.getValue().explicit()) {
if (indexVersionCreated.onOrAfter(Version.V_8_0_0)) {
throw new MapperParsingException("The `enabled` setting for the `_field_names` field has been deprecated and "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ boolean isConfigured() {
}

@Override
public abstract MetadataFieldMapper build(ContentPath contentPath);
public final MetadataFieldMapper build(ContentPath path) {
return build();
}

public abstract MetadataFieldMapper build();
}

protected MetadataFieldMapper(MappedFieldType mappedFieldType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected List<Parameter<?>> getParameters() {
}

@Override
public RoutingFieldMapper build(ContentPath contentPath) {
public RoutingFieldMapper build() {
return new RoutingFieldMapper(required.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected List<Parameter<?>> getParameters() {
}

@Override
public SourceFieldMapper build(ContentPath contentPath) {
public SourceFieldMapper build() {
return new SourceFieldMapper(enabled.getValue(),
includes.getValue().toArray(String[]::new),
excludes.getValue().toArray(String[]::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.mapper.ContentPath;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MapperParsingException;
Expand Down Expand Up @@ -1575,7 +1574,7 @@ protected List<FieldMapper.Parameter<?>> getParameters() {
}

@Override
public MetadataFieldMapper build(ContentPath contentPath) {
public MetadataFieldMapper build() {
return new MetadataTimestampFieldMapper(enabled.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.StringField;

import java.io.IOException;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class ExternalMetadataMapper extends MetadataFieldMapper {

static final String CONTENT_TYPE = "_external_root";
Expand All @@ -37,39 +32,16 @@ protected ExternalMetadataMapper() {
super(new BooleanFieldMapper.BooleanFieldType(FIELD_NAME));
}

@Override
public Iterator<Mapper> iterator() {
return Collections.emptyIterator();
}

@Override
protected String contentType() {
return CONTENT_TYPE;
}

@Override
public void postParse(ParseContext context) throws IOException {
public void postParse(ParseContext context) {
context.doc().add(new StringField(FIELD_NAME, FIELD_VALUE, Store.YES));
}

public static class Builder extends MetadataFieldMapper.Builder {

protected Builder() {
super(FIELD_NAME);
}

@Override
protected List<Parameter<?>> getParameters() {
return Collections.emptyList();
}

@Override
public ExternalMetadataMapper build(ContentPath contentPath) {
return new ExternalMetadataMapper();
}

}

public static final TypeParser PARSER = new ConfigurableTypeParser(c -> new ExternalMetadataMapper(), c -> new Builder());
public static final TypeParser PARSER = new FixedTypeParser(c -> new ExternalMetadataMapper());

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

import java.io.IOException;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -58,37 +56,12 @@ protected void parseCreateField(ParseContext context) throws IOException {
}
}

@Override
public Iterator<Mapper> iterator() {
return Collections.emptyIterator();
}

@Override
protected String contentType() {
return CONTENT_TYPE;
}

public static class Builder extends MetadataFieldMapper.Builder {

protected Builder() {
super(FIELD_NAME);
}

@Override
protected List<Parameter<?>> getParameters() {
return Collections.emptyList();
}

@Override
public MockMetadataMapper build(ContentPath contentPath) {
return new MockMetadataMapper();
}
}

public static final TypeParser PARSER = new ConfigurableTypeParser(
c -> new MockMetadataMapper(),
c -> new MockMetadataMapper.Builder()) {
};
public static final TypeParser PARSER = new FixedTypeParser(c -> new MockMetadataMapper());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.mapper.ContentPath;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
Expand Down Expand Up @@ -88,7 +87,7 @@ protected List<Parameter<?>> getParameters() {
}

@Override
public MetadataFieldMapper build(ContentPath contentPath) {
public MetadataFieldMapper build() {
return new DataStreamTimestampFieldMapper(new TimestampFieldType(), enabled.getValue());
}
}
Expand Down