Skip to content

Commit 4eaf674

Browse files
committed
remove allow_multiple_values parameter
1 parent 68a8d4a commit 4eaf674

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static class Builder extends FieldMapper.Builder {
116116
private final ScriptCompiler scriptCompiler;
117117
private final NumberType type;
118118

119-
private final Parameter<Boolean> allowMultipleValues;
119+
private boolean allowMultipleValues = true;
120120
private final Version indexCreatedVersion;
121121

122122
public Builder(String name, NumberType type, ScriptCompiler compiler, Settings settings, Version indexCreatedVersion) {
@@ -189,8 +189,6 @@ public Builder(
189189

190190
this.script.precludesParameters(ignoreMalformed, coerce, nullValue);
191191
addScriptValidation(script, indexed, hasDocValues);
192-
193-
this.allowMultipleValues = Parameter.boolParam("allow_multiple_values", false, m -> toType(m).allowMultipleValues, true);
194192
}
195193

196194
Builder nullValue(Number number) {
@@ -221,7 +219,7 @@ public Builder metric(MetricType metric) {
221219
}
222220

223221
public Builder allowMultipleValues(boolean allowMultipleValues) {
224-
this.allowMultipleValues.setValue(allowMultipleValues);
222+
this.allowMultipleValues = allowMultipleValues;
225223
return this;
226224
}
227225

@@ -238,8 +236,7 @@ protected Parameter<?>[] getParameters() {
238236
onScriptError,
239237
meta,
240238
dimension,
241-
metric,
242-
allowMultipleValues };
239+
metric };
243240
}
244241

245242
@Override
@@ -1555,7 +1552,7 @@ private NumberFieldMapper(String simpleName, MappedFieldType mappedFieldType, Mu
15551552
this.scriptCompiler = builder.scriptCompiler;
15561553
this.script = builder.script.getValue();
15571554
this.metricType = builder.metric.getValue();
1558-
this.allowMultipleValues = builder.allowMultipleValues.get();
1555+
this.allowMultipleValues = builder.allowMultipleValues;
15591556
this.indexCreatedVersion = builder.indexCreatedVersion;
15601557
}
15611558

@@ -1626,8 +1623,11 @@ private void indexValue(DocumentParserContext context, Number numericValue) {
16261623
// the last field is the current field, Add to the key map, so that we can validate if it has been added
16271624
List<IndexableField> fields = context.doc().getFields();
16281625
IndexableField last = fields.get(fields.size() - 1);
1629-
assert last.name().equals(fieldType().name())
1630-
: "last field name [" + last.name() + "] mis match field name [" + fieldType().name() + "]";
1626+
assert last.name().equals(fieldType().name()) : "last field name ["
1627+
+ last.name()
1628+
+ "] mis match field name ["
1629+
+ fieldType().name()
1630+
+ "]";
16311631
context.doc().onlyAddKey(fieldType().name(), fields.get(fields.size() - 1));
16321632
}
16331633

server/src/test/java/org/elasticsearch/index/mapper/NumberFieldMapperTests.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010

1111
import org.apache.lucene.index.DocValuesType;
1212
import org.apache.lucene.index.IndexableField;
13+
import org.elasticsearch.Version;
1314
import org.elasticsearch.common.Strings;
1415
import org.elasticsearch.core.Tuple;
16+
import org.elasticsearch.index.mapper.NumberFieldMapper.NumberType;
1517
import org.elasticsearch.index.mapper.NumberFieldTypeTests.OutOfRangeSpec;
1618
import org.elasticsearch.index.termvectors.TermVectorsService;
1719
import org.elasticsearch.script.DoubleFieldScript;
1820
import org.elasticsearch.script.LongFieldScript;
1921
import org.elasticsearch.script.Script;
22+
import org.elasticsearch.script.ScriptCompiler;
2023
import org.elasticsearch.script.ScriptContext;
2124
import org.elasticsearch.script.ScriptFactory;
2225
import org.elasticsearch.xcontent.XContentBuilder;
@@ -348,19 +351,6 @@ public void testScriptableTypes() throws IOException {
348351
}
349352
}
350353

351-
public void testAllowMultipleValuesField() throws IOException {
352-
DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> {
353-
minimalMapping(b);
354-
b.field("allow_multiple_values", false);
355-
}));
356-
357-
Exception e = expectThrows(
358-
MapperParsingException.class,
359-
() -> mapper.parse(source(b -> b.array("field", randomNumber(), randomNumber(), randomNumber())))
360-
);
361-
assertThat(e.getCause().getMessage(), containsString("Only one field can be stored per key"));
362-
}
363-
364354
protected abstract Number randomNumber();
365355

366356
protected final class NumberSyntheticSourceSupport implements SyntheticSourceSupport {

0 commit comments

Comments
 (0)