|
48 | 48 | import java.util.Objects;
|
49 | 49 | import java.util.Set;
|
50 | 50 | import java.util.function.Supplier;
|
| 51 | +import java.util.stream.Collectors; |
| 52 | +import java.util.stream.Stream; |
51 | 53 |
|
52 | 54 | import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_ROUTING_PATH;
|
53 | 55 | import static org.elasticsearch.xpack.logsdb.LogsDBPlugin.CLUSTER_LOGSDB_ENABLED;
|
54 | 56 |
|
55 | 57 | final class LogsdbIndexModeSettingsProvider implements IndexSettingProvider {
|
56 | 58 | private static final Logger LOGGER = LogManager.getLogger(LogsdbIndexModeSettingsProvider.class);
|
57 | 59 | static final String LOGS_PATTERN = "logs-*-*";
|
58 |
| - private static final Set<String> MAPPING_INCLUDES = Set.of( |
59 |
| - "_doc._source.*", |
60 |
| - "_doc.properties.host**", |
61 |
| - "_doc.properties.resource**", |
62 |
| - "_doc.subobjects" |
63 |
| - ); |
| 60 | + private static final Set<String> MAPPING_INCLUDES = Set.of("_source.*", "properties.host**", "properties.resource**", "subobjects") |
| 61 | + .stream() |
| 62 | + .flatMap(v -> Stream.of(v, "_doc." + v)) |
| 63 | + .collect(Collectors.toSet()); |
64 | 64 |
|
65 | 65 | private final LogsdbLicenseService licenseService;
|
66 | 66 | private final SetOnce<CheckedFunction<IndexMetadata, MapperService, IOException>> mapperServiceFactory = new SetOnce<>();
|
@@ -305,11 +305,11 @@ MappingHints getMappingHints(
|
305 | 305 | @SuppressWarnings("unchecked")
|
306 | 306 | private boolean checkMappingForPatternText(Map<String, Object> mapping) {
|
307 | 307 | var docMapping = mapping.get("_doc");
|
308 |
| - if ((docMapping instanceof Map) == false) { |
309 |
| - return false; |
| 308 | + if (docMapping instanceof Map) { |
| 309 | + mapping = (Map<String, Object>) docMapping; |
310 | 310 | }
|
311 | 311 | boolean[] usesPatternText = { false };
|
312 |
| - MappingVisitor.visitMapping((Map<String, Object>) docMapping, (field, fieldMapping) -> { |
| 312 | + MappingVisitor.visitMapping(mapping, (field, fieldMapping) -> { |
313 | 313 | if (Objects.equals(fieldMapping.get("type"), PatternTextFieldType.CONTENT_TYPE)) {
|
314 | 314 | usesPatternText[0] = true;
|
315 | 315 | }
|
|
0 commit comments