We were correctly dealing with boosts that had an effect, but mappers that had a silently accepted but ignored boost parameter were throwing an error instead of continuing to ignore the boost but emitting a warning. Fixes #64982
This commit is contained in:
parent
d9970fa764
commit
caf143f4a5
|
@ -94,6 +94,11 @@ public class TokenCountFieldMapperTests extends MapperTestCase {
|
|||
return new IndexAnalyzers(analyzers, Collections.emptyMap(), Collections.emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeName() {
|
||||
return "token_count";
|
||||
}
|
||||
|
||||
/**
|
||||
* When position increments are counted, we're looking to make sure that we:
|
||||
- don't count tokens without an increment
|
||||
|
|
|
@ -634,7 +634,7 @@ public abstract class ParametrizedFieldMapper extends FieldMapper {
|
|||
// made no sense; if we've got here, that means that they're not declared on a current mapper,
|
||||
// and so we emit a deprecation warning rather than failing a previously working mapping.
|
||||
private static final Set<String> DEPRECATED_PARAMS
|
||||
= new HashSet<>(Arrays.asList("store", "meta", "index", "doc_values", "index_options", "similarity"));
|
||||
= new HashSet<>(Arrays.asList("store", "meta", "boost", "index", "doc_values", "index_options", "similarity"));
|
||||
|
||||
private static boolean isDeprecatedParameter(String propName, Version indexCreatedVersion) {
|
||||
return DEPRECATED_PARAMS.contains(propName);
|
||||
|
|
|
@ -45,6 +45,11 @@ public class GeoShapeFieldMapperTests extends FieldMapperTestCase2<GeoShapeField
|
|||
return org.elasticsearch.common.collect.Set.of("analyzer", "similarity", "doc_values", "store");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportsOrIgnoresBoost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GeoShapeFieldMapper.Builder newBuilder() {
|
||||
return new GeoShapeFieldMapper.Builder("geoshape");
|
||||
|
|
|
@ -69,6 +69,11 @@ public class LegacyGeoShapeFieldMapperTests extends FieldMapperTestCase2<LegacyG
|
|||
return org.elasticsearch.common.collect.Set.of("analyzer", "similarity", "doc_values", "store");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportsOrIgnoresBoost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void minimalMapping(XContentBuilder b) throws IOException {
|
||||
b.field("type", "geo_shape").field("strategy", "recursive");
|
||||
|
|
|
@ -246,20 +246,26 @@ public abstract class MapperTestCase extends MapperServiceTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
protected String typeName() throws IOException {
|
||||
MapperService ms = createMapperService(fieldMapping(this::minimalMapping));
|
||||
return ms.fieldType("field").typeName();
|
||||
}
|
||||
|
||||
protected boolean supportsOrIgnoresBoost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final void testDeprecatedBoost() throws IOException {
|
||||
try {
|
||||
createMapperService(fieldMapping(b -> {
|
||||
minimalMapping(b);
|
||||
b.field("boost", 2.0);
|
||||
}));
|
||||
assertWarnings("Parameter [boost] on field [field] is deprecated and will be removed in 8.0");
|
||||
}
|
||||
catch (MapperParsingException e) {
|
||||
assertThat(e.getMessage(), anyOf(
|
||||
containsString("unknown parameter [boost]"),
|
||||
containsString("[boost : 2.0]")));
|
||||
}
|
||||
assertParseMinimalWarnings();
|
||||
assumeTrue("Does not support [boost] parameter", supportsOrIgnoresBoost());
|
||||
createMapperService(fieldMapping(b -> {
|
||||
minimalMapping(b);
|
||||
b.field("boost", 2.0);
|
||||
}));
|
||||
String type = typeName();
|
||||
String[] warnings = new String[] {
|
||||
"Parameter [boost] on field [field] is deprecated and will be removed in 8.0",
|
||||
"Parameter [boost] has no effect on type [" + type + "] and will be removed in future" };
|
||||
allowedWarnings(warnings);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue