From cc3a20eb8bc5392abefb7e01f4e07010acfc8d71 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 29 Apr 2021 14:23:14 +0100 Subject: [PATCH] Explicitly say if stored fields aren't supported in MapperTestCase --- .../mapper/MatchOnlyTextFieldMapperTests.java | 6 +++++ .../mapper/RankFeatureFieldMapperTests.java | 5 ++++ .../mapper/RankFeaturesFieldMapperTests.java | 5 ++++ .../mapper/CompletionFieldMapperTests.java | 5 ++++ .../mapper/GeoShapeFieldMapperTests.java | 5 ++++ .../LegacyGeoShapeFieldMapperTests.java | 5 ++++ .../flattened/FlattenedFieldMapperTests.java | 5 ++++ .../index/mapper/MapperTestCase.java | 24 +++++++++---------- .../mapper/HistogramFieldMapperTests.java | 5 ++++ ...AggregateDoubleMetricFieldMapperTests.java | 5 ++++ .../ConstantKeywordFieldMapperTests.java | 5 ++++ .../VersionStringFieldMapperTests.java | 5 ++++ ...GeoShapeWithDocValuesFieldMapperTests.java | 5 ++++ .../index/mapper/ShapeFieldMapperTests.java | 5 ++++ .../mapper/DenseVectorFieldMapperTests.java | 5 ++++ .../mapper/WildcardFieldMapperTests.java | 5 ++++ 16 files changed, 88 insertions(+), 12 deletions(-) diff --git a/modules/mapper-extras/src/internalClusterTest/java/org/elasticsearch/index/mapper/MatchOnlyTextFieldMapperTests.java b/modules/mapper-extras/src/internalClusterTest/java/org/elasticsearch/index/mapper/MatchOnlyTextFieldMapperTests.java index dfb76b663695a..617dae6b05065 100644 --- a/modules/mapper-extras/src/internalClusterTest/java/org/elasticsearch/index/mapper/MatchOnlyTextFieldMapperTests.java +++ b/modules/mapper-extras/src/internalClusterTest/java/org/elasticsearch/index/mapper/MatchOnlyTextFieldMapperTests.java @@ -61,6 +61,12 @@ protected void minimalMapping(XContentBuilder b) throws IOException { b.field("type", "match_only_text"); } + @Override + protected void minimalStoreMapping(XContentBuilder b) throws IOException { + // 'store' is always true + minimalMapping(b); + } + public void testDefaults() throws IOException { DocumentMapper mapper = createDocumentMapper(fieldMapping(this::minimalMapping)); assertEquals(Strings.toString(fieldMapping(this::minimalMapping)), mapper.mappingSource().toString()); diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeatureFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeatureFieldMapperTests.java index 27e13c4e6b60f..e7cd312457f4b 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeatureFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeatureFieldMapperTests.java @@ -52,6 +52,11 @@ protected void assertSearchable(MappedFieldType fieldType) { assertTrue(fieldType.isSearchable()); } + @Override + protected boolean supportsStoredFields() { + return false; + } + @Override protected Collection getPlugins() { return List.of(new MapperExtrasPlugin()); diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapperTests.java index a1b14312266b7..1b932d548daa7 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapperTests.java @@ -46,6 +46,11 @@ protected void minimalMapping(XContentBuilder b) throws IOException { b.field("type", "rank_features"); } + @Override + protected boolean supportsStoredFields() { + return false; + } + @Override protected void registerParameters(ParameterChecker checker) throws IOException { checker.registerConflictCheck("positive_score_impact", b -> b.field("positive_score_impact", false)); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java index ec46fb440e91e..51f0450ea2edc 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java @@ -73,6 +73,11 @@ protected void metaMapping(XContentBuilder b) throws IOException { b.field("max_input_length", 50); } + @Override + protected boolean supportsStoredFields() { + return false; + } + @Override protected void registerParameters(ParameterChecker checker) throws IOException { checker.registerConflictCheck("analyzer", b -> b.field("analyzer", "standard")); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java index f86f78266a9ec..86e112f93d8f1 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java @@ -56,6 +56,11 @@ protected void minimalMapping(XContentBuilder b) throws IOException { b.field("type", "geo_shape"); } + @Override + protected boolean supportsStoredFields() { + return false; + } + @Override protected Object getSampleValueForDocument() { return "POINT (14.0 15.0)"; diff --git a/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java index 552d8d81cc383..31cbb64ceed76 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java @@ -54,6 +54,11 @@ protected void minimalMapping(XContentBuilder b) throws IOException { b.field("type", "geo_shape").field("strategy", "recursive"); } + @Override + protected boolean supportsStoredFields() { + return false; + } + @Override protected void registerParameters(ParameterChecker checker) throws IOException { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/flattened/FlattenedFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/flattened/FlattenedFieldMapperTests.java index fbfbc0f1a2175..b6ed5a0c64af1 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/flattened/FlattenedFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/flattened/FlattenedFieldMapperTests.java @@ -65,6 +65,11 @@ protected void registerParameters(ParameterChecker checker) throws IOException { m -> assertEquals(10, ((FlattenedFieldMapper)m).depthLimit())); } + @Override + protected boolean supportsStoredFields() { + return false; + } + public void testDefaults() throws Exception { DocumentMapper mapper = createDocumentMapper(fieldMapping(this::minimalMapping)); ParsedDocument parsedDoc = mapper.parse(source(b -> b.startObject("field").field("key", "value").endObject())); diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java index 2f9ab57f2292f..cbc4c677db247 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java @@ -643,24 +643,24 @@ public final void testIndexTimeFieldData() throws IOException { }); } + protected boolean supportsStoredFields() { + return true; + } + + protected void minimalStoreMapping(XContentBuilder b) throws IOException { + minimalMapping(b); + b.field("store", true); + } + /** * Checks that loading stored fields for this field produces the same set of values * for query time scripts and index time scripts */ public final void testIndexTimeStoredFieldsAccess() throws IOException { - MapperService mapperService; - try { - mapperService = createMapperService(fieldMapping(b -> { - minimalMapping(b); - b.field("store", true); - })); - assertParseMinimalWarnings(); - } catch (MapperParsingException e) { - assertParseMinimalWarnings(); - assumeFalse("Field type does not support stored fields", true); - return; - } + assumeTrue("Field type does not support stored fields", supportsStoredFields()); + MapperService mapperService = createMapperService(fieldMapping(this::minimalStoreMapping)); + assertParseMinimalWarnings(); MappedFieldType fieldType = mapperService.fieldType("field"); SourceToParse source = source(this::writeField); diff --git a/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapperTests.java b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapperTests.java index f620791baf7a8..b5809dfc099dc 100644 --- a/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapperTests.java +++ b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapperTests.java @@ -54,6 +54,11 @@ protected boolean supportsSearchLookup() { return false; } + @Override + protected boolean supportsStoredFields() { + return false; + } + public void testParseValue() throws Exception { DocumentMapper mapper = createDocumentMapper(fieldMapping(this::minimalMapping)); ParsedDocument doc = mapper.parse( diff --git a/x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapperTests.java b/x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapperTests.java index 1fae26787d5a3..540815f3d2229 100644 --- a/x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapperTests.java +++ b/x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapperTests.java @@ -99,6 +99,11 @@ protected Object getSampleValueForQuery() { return 50.0; } + @Override + protected boolean supportsStoredFields() { + return false; + } + /** * Test parsing field mapping and adding simple field */ diff --git a/x-pack/plugin/mapper-constant-keyword/src/internalClusterTest/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapperTests.java b/x-pack/plugin/mapper-constant-keyword/src/internalClusterTest/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapperTests.java index 6ef8fd691a45f..ab255cf34bc28 100644 --- a/x-pack/plugin/mapper-constant-keyword/src/internalClusterTest/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapperTests.java +++ b/x-pack/plugin/mapper-constant-keyword/src/internalClusterTest/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapperTests.java @@ -58,6 +58,11 @@ protected Collection getPlugins() { return List.of(new ConstantKeywordMapperPlugin()); } + @Override + protected boolean supportsStoredFields() { + return false; + } + public void testDefaults() throws Exception { XContentBuilder mapping = fieldMapping(b -> b.field("type", "constant_keyword").field("value", "foo")); DocumentMapper mapper = createDocumentMapper(mapping); diff --git a/x-pack/plugin/mapper-version/src/test/java/org/elasticsearch/xpack/versionfield/VersionStringFieldMapperTests.java b/x-pack/plugin/mapper-version/src/test/java/org/elasticsearch/xpack/versionfield/VersionStringFieldMapperTests.java index 3eb84d3a62c8d..84b1627361389 100644 --- a/x-pack/plugin/mapper-version/src/test/java/org/elasticsearch/xpack/versionfield/VersionStringFieldMapperTests.java +++ b/x-pack/plugin/mapper-version/src/test/java/org/elasticsearch/xpack/versionfield/VersionStringFieldMapperTests.java @@ -52,6 +52,11 @@ protected void registerParameters(ParameterChecker checker) throws IOException { // no configurable parameters } + @Override + protected boolean supportsStoredFields() { + return false; + } + public void testDefaults() throws Exception { XContentBuilder mapping = fieldMapping(this::minimalMapping); DocumentMapper mapper = createDocumentMapper(mapping); diff --git a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapperTests.java b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapperTests.java index 72edb57324194..3a37124f5e0a5 100644 --- a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapperTests.java +++ b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapperTests.java @@ -59,6 +59,11 @@ protected boolean supportsSearchLookup() { return false; } + @Override + protected boolean supportsStoredFields() { + return false; + } + @Override protected void registerParameters(ParameterChecker checker) throws IOException { checker.registerConflictCheck("doc_values", b -> b.field("doc_values", false)); diff --git a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/ShapeFieldMapperTests.java b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/ShapeFieldMapperTests.java index 12ddd8c194137..acb06143e4096 100644 --- a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/ShapeFieldMapperTests.java +++ b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/ShapeFieldMapperTests.java @@ -53,6 +53,11 @@ protected void registerParameters(ParameterChecker checker) throws IOException { }); } + @Override + protected boolean supportsStoredFields() { + return false; + } + public void testDefaultConfiguration() throws IOException { DocumentMapper mapper = createDocumentMapper(fieldMapping(this::minimalMapping)); Mapper fieldMapper = mapper.mappers().getMapper(FIELD_NAME); diff --git a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapperTests.java b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapperTests.java index 930015f1fb298..ec9a284b37202 100644 --- a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapperTests.java +++ b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapperTests.java @@ -53,6 +53,11 @@ protected void registerParameters(ParameterChecker checker) throws IOException { fieldMapping(b -> b.field("type", "dense_vector").field("dims", 5))); } + @Override + protected boolean supportsStoredFields() { + return false; + } + public void testDims() { { Exception e = expectThrows(MapperParsingException.class, () -> createMapperService(fieldMapping(b -> { diff --git a/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java b/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java index 5b48a20e90119..38fb5b1603758 100644 --- a/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java +++ b/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java @@ -102,6 +102,11 @@ protected Collection getPlugins() { return Collections.singleton(new Wildcard()); } + @Override + protected boolean supportsStoredFields() { + return false; + } + @Override @Before public void setUp() throws Exception {