Remove version argument in RangeFieldType (#30411)

The argument `indexVersionCreated` is not needed any more and
can be removed.
This commit is contained in:
Ke Li 2018-05-16 23:42:44 +08:00 committed by Christoph Büscher
parent 41887e85df
commit d2b9a765cf
3 changed files with 9 additions and 10 deletions

View File

@ -161,7 +161,7 @@ public class PercolatorFieldMapper extends FieldMapper {
}
static RangeFieldMapper createExtractedRangeFieldBuilder(String name, RangeType rangeType, BuilderContext context) {
RangeFieldMapper.Builder builder = new RangeFieldMapper.Builder(name, rangeType, context.indexCreatedVersion());
RangeFieldMapper.Builder builder = new RangeFieldMapper.Builder(name, rangeType);
// For now no doc values, because in processQuery(...) only the Lucene range fields get added:
builder.docValues(false);
return builder.build(context);

View File

@ -40,7 +40,6 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.ByteArrayDataOutput;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.common.Explicit;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.collect.Tuple;
@ -93,8 +92,8 @@ public class RangeFieldMapper extends FieldMapper {
private Boolean coerce;
private Locale locale;
public Builder(String name, RangeType type, Version indexVersionCreated) {
super(name, new RangeFieldType(type, indexVersionCreated), new RangeFieldType(type, indexVersionCreated));
public Builder(String name, RangeType type) {
super(name, new RangeFieldType(type), new RangeFieldType(type));
builder = this;
locale = Locale.ROOT;
}
@ -174,7 +173,7 @@ public class RangeFieldMapper extends FieldMapper {
@Override
public Mapper.Builder<?,?> parse(String name, Map<String, Object> node,
ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(name, type, parserContext.indexVersionCreated());
Builder builder = new Builder(name, type);
TypeParsers.parseField(builder, name, node, parserContext);
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, Object> entry = iterator.next();
@ -205,7 +204,7 @@ public class RangeFieldMapper extends FieldMapper {
protected FormatDateTimeFormatter dateTimeFormatter;
protected DateMathParser dateMathParser;
RangeFieldType(RangeType type, Version indexVersionCreated) {
RangeFieldType(RangeType type) {
super();
this.rangeType = Objects.requireNonNull(type);
setTokenized(false);

View File

@ -77,12 +77,12 @@ public class RangeFieldTypeTests extends FieldTypeTestCase {
@Override
protected RangeFieldType createDefaultFieldType() {
return new RangeFieldType(type, Version.CURRENT);
return new RangeFieldType(type);
}
public void testRangeQuery() throws Exception {
QueryShardContext context = createContext();
RangeFieldType ft = new RangeFieldType(type, Version.CURRENT);
RangeFieldType ft = new RangeFieldType(type);
ft.setName(FIELDNAME);
ft.setIndexOptions(IndexOptions.DOCS);
@ -106,7 +106,7 @@ public class RangeFieldTypeTests extends FieldTypeTestCase {
public void testDateRangeQueryUsingMappingFormat() {
QueryShardContext context = createContext();
RangeFieldType fieldType = new RangeFieldType(RangeType.DATE, Version.CURRENT);
RangeFieldType fieldType = new RangeFieldType(RangeType.DATE);
fieldType.setName(FIELDNAME);
fieldType.setIndexOptions(IndexOptions.DOCS);
fieldType.setHasDocValues(false);
@ -313,7 +313,7 @@ public class RangeFieldTypeTests extends FieldTypeTestCase {
public void testTermQuery() throws Exception {
// See https://github.com/elastic/elasticsearch/issues/25950
QueryShardContext context = createContext();
RangeFieldType ft = new RangeFieldType(type, Version.CURRENT);
RangeFieldType ft = new RangeFieldType(type);
ft.setName(FIELDNAME);
ft.setIndexOptions(IndexOptions.DOCS);