Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] Fix generation of dynamic mapping for object with specific subf…
…ield (#204104) (#204493) # Backport This will backport the following commits from `main` to `8.x`: - [Fix generation of dynamic mapping for object with specific subfield (#204104)](#204104) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Jaime Soriano Pastor","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-16T20:58:30Z","message":"Fix generation of dynamic mapping for object with specific subfield (#204104)\n\nFix generation of dynamic mapping for objects that have more specific\r\nsubfields in separate definitions.\r\n\r\nThis can be reproduced for example with:\r\n```\r\n- name: labels\r\n type: object\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n- name: labels.count\r\n type: long\r\n```\r\n\r\nFleet expands and deduplicates field definitions before generating the\r\nmappings, so the definitions above are converted to something like the\r\nfollowing:\r\n```\r\n- name: labels\r\n type: group\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n fields:\r\n - name: count\r\n type: long\r\n```\r\n\r\nUsually fields of type `group` don't have an `object_type`, so this was\r\nbeing ignored, the dynamic mapping was not being generated.\r\n\r\nThis issue was not reproduced if the object field name includes a\r\nwildcard, like in `labels.*`, because then the expansion and\r\ndeduplication resolves to something like this:\r\n```\r\n- name: labels\r\n type: group\r\n fields:\r\n - name: '*'\r\n type: object\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n - name: count\r\n type: long\r\n```","sha":"e3877e053405bae71b5576648cb7c637c4a23f9a","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","v9.0.0","backport:prev-major"],"title":"Fix generation of dynamic mapping for object with specific subfield","number":204104,"url":"https://github.com/elastic/kibana/pull/204104","mergeCommit":{"message":"Fix generation of dynamic mapping for object with specific subfield (#204104)\n\nFix generation of dynamic mapping for objects that have more specific\r\nsubfields in separate definitions.\r\n\r\nThis can be reproduced for example with:\r\n```\r\n- name: labels\r\n type: object\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n- name: labels.count\r\n type: long\r\n```\r\n\r\nFleet expands and deduplicates field definitions before generating the\r\nmappings, so the definitions above are converted to something like the\r\nfollowing:\r\n```\r\n- name: labels\r\n type: group\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n fields:\r\n - name: count\r\n type: long\r\n```\r\n\r\nUsually fields of type `group` don't have an `object_type`, so this was\r\nbeing ignored, the dynamic mapping was not being generated.\r\n\r\nThis issue was not reproduced if the object field name includes a\r\nwildcard, like in `labels.*`, because then the expansion and\r\ndeduplication resolves to something like this:\r\n```\r\n- name: labels\r\n type: group\r\n fields:\r\n - name: '*'\r\n type: object\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n - name: count\r\n type: long\r\n```","sha":"e3877e053405bae71b5576648cb7c637c4a23f9a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204104","number":204104,"mergeCommit":{"message":"Fix generation of dynamic mapping for object with specific subfield (#204104)\n\nFix generation of dynamic mapping for objects that have more specific\r\nsubfields in separate definitions.\r\n\r\nThis can be reproduced for example with:\r\n```\r\n- name: labels\r\n type: object\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n- name: labels.count\r\n type: long\r\n```\r\n\r\nFleet expands and deduplicates field definitions before generating the\r\nmappings, so the definitions above are converted to something like the\r\nfollowing:\r\n```\r\n- name: labels\r\n type: group\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n fields:\r\n - name: count\r\n type: long\r\n```\r\n\r\nUsually fields of type `group` don't have an `object_type`, so this was\r\nbeing ignored, the dynamic mapping was not being generated.\r\n\r\nThis issue was not reproduced if the object field name includes a\r\nwildcard, like in `labels.*`, because then the expansion and\r\ndeduplication resolves to something like this:\r\n```\r\n- name: labels\r\n type: group\r\n fields:\r\n - name: '*'\r\n type: object\r\n object_type: keyword\r\n object_type_mapping_type: '*'\r\n - name: count\r\n type: long\r\n```","sha":"e3877e053405bae71b5576648cb7c637c4a23f9a"}}]}] BACKPORT--> Co-authored-by: Jaime Soriano Pastor <[email protected]>
- Loading branch information