Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly say if stored fields aren't supported in MapperTestCase #72474

Merged
merged 1 commit into from
Apr 30, 2021
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 @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ protected void assertSearchable(MappedFieldType fieldType) {
assertTrue(fieldType.isSearchable());
}

@Override
protected boolean supportsStoredFields() {
return false;
}

@Override
protected Collection<? extends Plugin> getPlugins() {
return List.of(new MapperExtrasPlugin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much nicer :)


MappedFieldType fieldType = mapperService.fieldType("field");
SourceToParse source = source(this::writeField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ protected Object getSampleValueForQuery() {
return 50.0;
}

@Override
protected boolean supportsStoredFields() {
return false;
}

/**
* Test parsing field mapping and adding simple field
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ protected Collection<Plugin> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ protected Collection<? extends Plugin> getPlugins() {
return Collections.singleton(new Wildcard());
}

@Override
protected boolean supportsStoredFields() {
return false;
}

@Override
@Before
public void setUp() throws Exception {
Expand Down