Skip to content

Commit b1aa0d8

Browse files
authored
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
1 parent a214d79 commit b1aa0d8

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public void setType() {
9898
type = getOldClusterVersion().before(Version.V_6_7_0) ? "doc" : "_doc";
9999
}
100100

101-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/57245")
102101
public void testSearch() throws Exception {
103102
int count;
104103
if (isRunningAgainstOldCluster()) {

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
235235
}
236236
for (String path : paths) {
237237
for (String fieldName : extractFieldNames(path)) {
238-
if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) {
239-
document.add(new Field(fieldType().name(), fieldName, fieldType));
240-
}
238+
document.add(new Field(fieldType().name(), fieldName, Defaults.FIELD_TYPE));
241239
}
242240
}
243241
}

0 commit comments

Comments
 (0)