Fix fieldnames field type for pre-6.1 indexes (#61322)

The FieldNamesFieldMapper field has different behaviour for indexes created in
clusters earlier than v6.1, and the code to deal with this was still using the vestigial
FieldType field of FieldMapper in its indexing path. This meant that documents
added after an upgrade were not correctly indexing their field names field. This
commit corrects the parseCreateField method to use the default field type.

Fixes #61305
This commit is contained in:
Alan Woodward 2020-08-19 12:59:09 +01:00 committed by GitHub
parent a214d7902a
commit b1aa0d8731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 4 deletions

View File

@ -98,7 +98,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
type = getOldClusterVersion().before(Version.V_6_7_0) ? "doc" : "_doc";
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/57245")
public void testSearch() throws Exception {
int count;
if (isRunningAgainstOldCluster()) {

View File

@ -235,9 +235,7 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
}
for (String path : paths) {
for (String fieldName : extractFieldNames(path)) {
if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) {
document.add(new Field(fieldType().name(), fieldName, fieldType));
}
document.add(new Field(fieldType().name(), fieldName, Defaults.FIELD_TYPE));
}
}
}