|
14 | 14 | import org.elasticsearch.core.Nullable; |
15 | 15 | import org.elasticsearch.index.IndexService; |
16 | 16 | import org.elasticsearch.index.engine.Engine; |
| 17 | +import org.elasticsearch.index.mapper.FieldMapper; |
17 | 18 | import org.elasticsearch.index.mapper.MappedFieldType; |
| 19 | +import org.elasticsearch.index.mapper.RootObjectMapper; |
18 | 20 | import org.elasticsearch.index.mapper.RuntimeField; |
19 | 21 | import org.elasticsearch.index.query.MatchAllQueryBuilder; |
20 | 22 | import org.elasticsearch.index.query.QueryBuilder; |
|
30 | 32 | import org.elasticsearch.tasks.CancellableTask; |
31 | 33 |
|
32 | 34 | import java.io.IOException; |
| 35 | +import java.util.ArrayList; |
33 | 36 | import java.util.Collections; |
34 | 37 | import java.util.HashMap; |
| 38 | +import java.util.List; |
35 | 39 | import java.util.Map; |
36 | 40 | import java.util.Set; |
37 | 41 | import java.util.function.Predicate; |
@@ -165,16 +169,21 @@ static Map<String, IndexFieldCapabilities> retrieveFieldCaps( |
165 | 169 | var fieldInfos = indexShard.getFieldInfos(); |
166 | 170 | includeEmptyFields = includeEmptyFields || enableFieldHasValue == false; |
167 | 171 | Map<String, IndexFieldCapabilities> responseMap = new HashMap<>(); |
168 | | - for (Map.Entry<String, MappedFieldType> entry : context.getAllFields()) { |
169 | | - final String field = entry.getKey(); |
| 172 | + |
| 173 | + RootObjectMapper rootObjectMapper = context.getMappingLookup().getMapping().getRoot(); |
| 174 | + List<FieldMapper> allMappers = new ArrayList<>(); |
| 175 | + allMappers.addAll(rootObjectMapper.getSourceFields()); |
| 176 | + allMappers.addAll(context.getMetadataFields()); |
| 177 | + |
| 178 | + for (FieldMapper mapper : allMappers) { |
| 179 | + final String field = mapper.fullPath(); |
170 | 180 | if (fieldNameFilter.test(field) == false) { |
171 | 181 | continue; |
172 | 182 | } |
173 | | - MappedFieldType ft = entry.getValue(); |
| 183 | + MappedFieldType ft = mapper.fieldType(); |
174 | 184 | if ((includeEmptyFields || ft.fieldHasValue(fieldInfos)) |
175 | 185 | && (fieldPredicate.test(ft.name()) || context.isMetadataField(ft.name())) |
176 | | - && (filter == null || filter.test(ft)) |
177 | | - && ft.excludeFromFieldCaps() == false) { |
| 186 | + && (filter == null || filter.test(ft))) { |
178 | 187 | IndexFieldCapabilities fieldCap = new IndexFieldCapabilities( |
179 | 188 | field, |
180 | 189 | ft.familyTypeName(), |
|
0 commit comments