Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mappings Editor] Add support for synthetic _source #199854

Merged

Conversation

ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Nov 12, 2024

Closes #198621

Summary

This PR adds support for the synthetic _source field in the mappings Advanced options.

Stored option:
Screenshot 2024-11-14 at 19 19 19

Synthetic option selected:
Screenshot 2024-11-14 at 19 19 27

Disabled option selected:
Screenshot 2024-11-14 at 19 19 36

synthetic_source.mov

How to test:

  1. Start Es with yarn es snapshot --license (we need Enterprise license to see the Synthetic source option) and Kibana with yarn start
  2. Go to Index templates/Component templates and start creating a template
  3. At the Mappings step, go to Advanced options.
  4. Verify that selecting a _source field option translates to the correct Es request.
  5. In Index templates form, verify that the default _source option depends on the index mode selected in the Logistics step. For LogsDB and Time series index mode, the default should be synthetic mode; otherwise, the stored option.
  6. Verify that in Basic license, the synthetic option is not displayed.

Checklist

@ElenaStoeva ElenaStoeva added Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes Feature:Mappings Editor Index mappings editor UI v9.0.0 backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.17.0 labels Nov 12, 2024
@ElenaStoeva ElenaStoeva self-assigned this Nov 12, 2024
@ElenaStoeva ElenaStoeva force-pushed the mappings-configuration/source-field branch from b234d7a to 96ec5ac Compare November 12, 2024 18:40
@ElenaStoeva ElenaStoeva force-pushed the mappings-configuration/source-field branch from 1b18c86 to 32d6672 Compare November 14, 2024 19:15
@ElenaStoeva ElenaStoeva marked this pull request as ready for review November 14, 2024 19:29
@ElenaStoeva ElenaStoeva requested review from a team as code owners November 14, 2024 19:29
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

Copy link
Contributor

@florent-leborgne florent-leborgne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy LGTM

@@ -27,7 +77,7 @@ export const SourceFieldSection = () => {
<p>
<FormattedMessage
id="xpack.idxMgmt.mappingsEditor.disabledSourceFieldCallOutDescription1"
defaultMessage="Disabling {source} lowers storage overhead within the index, but this comes at a cost. It also disables important features, such as the ability to reindex or debug queries by viewing the original document."
defaultMessage="Disabling {source} is not recommended. If storage overhead is a concer, consider using synthetic {source} instead. Disabling {source} will disable important features, such as the ability to reindex or debug queries by viewing the original document."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defaultMessage="Disabling {source} is not recommended. If storage overhead is a concer, consider using synthetic {source} instead. Disabling {source} will disable important features, such as the ability to reindex or debug queries by viewing the original document."
defaultMessage="Disabling {source} is not recommended. If storage overhead is a concern, consider using synthetic {source} instead. Disabling {source} will disable important features, such as the ability to reindex or debug queries by viewing the original document."

Copy link
Contributor Author

@ElenaStoeva ElenaStoeva Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @florent-leborgne! Fixed the typo with aa2b19b.

@ElenaStoeva ElenaStoeva marked this pull request as draft November 18, 2024 10:12
@ElenaStoeva
Copy link
Contributor Author

Converted back to a draft as I found one issue with setting synthetic source when index mode is logsdb/time series.

@ElenaStoeva ElenaStoeva marked this pull request as ready for review November 18, 2024 18:06
@sabarasaba sabarasaba self-requested a review November 19, 2024 11:51
@ElenaStoeva ElenaStoeva force-pushed the mappings-configuration/source-field branch from cdc8827 to 12d3b27 Compare November 19, 2024 12:18
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
indexManagement 698 700 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
aiAssistantManagementSelection 92.5KB 92.5KB +78.0B
indexManagement 694.7KB 698.1KB +3.4KB
lists 144.9KB 145.0KB +78.0B
total +3.5KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 453.9KB 453.9KB +78.0B

History

cc @ElenaStoeva

Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @ElenaStoeva! Tested locally and changes lgtm, left two small comments but for sake of speed might be worth to revise in a subsequent PR. What I do would like to see though, is perhaps a test for the license check to make sure the synthetic option isn't show with a basic license. wdyt?

@@ -120,6 +128,40 @@ export const MappingsEditor = React.memo(
[dispatch]
);

const [isLicenseCheckComplete, setIsLicenseCheckComplete] = useState(false);
useEffect(() => {
const subscription = licensing?.license$.subscribe((license: ILicense) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about extracting the license check subcription check into the plugin level and just pass something like canUseSyntheticOption variable into the renderApp method? that way we dont have tightly coupled logic and if the license condition changes its easier to update (I think we did something similar for checking if the user can use the new api key trust model in remote clusters)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great idea! This might actually help with testing if the synthetic option is displayed or not based on the license. I think the issues that I face now might be due to the fact that in the initial render the check is not complete and so the synthetic option is not displayed even when it should.

@@ -37,12 +48,30 @@ const formSerializer = (formData: GenericObject, sourceFieldMode?: string) => {
? 'strict'
: dynamicMapping?.enabled;

const _source =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It might just be me, but this seems a little too complex to read at first glance. Perhaps a more explicit structure could make future extensions more straightforward? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally understand! I did my best to make it as clear as possible but it's a bit tricky given that the sourceField.option field actually controls two properties in Es (mode and enabled). We also don't want to add the mode property if the field is undefined (which means it hasn't been set by the user) - otherwise, just opening the "Advanced options" tab would insert a "mode" property which is a behavior that we recently managed to fix in this form. I'm open to any suggestions for shortening/simplifying the code.

@ElenaStoeva
Copy link
Contributor Author

ElenaStoeva commented Nov 19, 2024

Many thanks for the review @sabarasaba! Yes, I also think we can address these comments in a separate PR so that we can merge this today.

What I do would like to see though, is perhaps a test for the license check to make sure the synthetic option isn't show with a basic license. wdyt?

Haha trust me, I'd also love to see this 😆 I spent quite a bit of time trying to implement these but it turned out trickier than I hoped. I initially added such tests with 32d6672 but then I had to change the implementation and they no longer worked as now the license check is performed in the parent component (the Mappings editor) instead of the Configuration form. I also tried adding these tests in the mappings_editor.test.tsx, but for some reason Jest cannot find any of the options at all (it seems they are not rendered, could be because we use EuiSuperSelect which needs to be mocked). I tried many different approaches but nothing worked so far.

I think if we refactor the license check code as you suggested these tests might be easier to implement.

Edit: Opened an issue for the improvements: #200769

Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving so we can get it merged today, and we can patch the rest of the feedback in a subsequent PR 🚀

@ElenaStoeva ElenaStoeva merged commit 8be679a into elastic:main Nov 19, 2024
23 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11917791552

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 19, 2024
Closes elastic#198621

## Summary

This PR adds support for the synthetic _source field in the mappings
Advanced options.

Stored option:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 19"
src="https://github.com/user-attachments/assets/086f7a3e-9ca1-42de-9f9c-d3599d839ccf">

Synthetic option selected:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 27"
src="https://github.com/user-attachments/assets/3700bced-212a-4378-b51a-ab7a0f4f7b99">

Disabled option selected:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 36"
src="https://github.com/user-attachments/assets/c7ddcbae-7c78-4477-824e-99b144a1f750">

https://github.com/user-attachments/assets/399d0f95-a5dd-4874-bb8c-e95d6ed38465

How to test:
1. Start Es with `yarn es snapshot --license` (we need Enterprise
license to see the Synthetic source option) and Kibana with `yarn start`
2. Go to Index templates/Component templates and start creating a
template
3. At the Mappings step, go to Advanced options.
4. Verify that selecting a _source field option translates to the
correct Es request.
5. In Index templates form, verify that the default _source option
depends on the index mode selected in the Logistics step. For LogsDB and
Time series index mode, the default should be synthetic mode; otherwise,
the stored option.
6. Verify that in Basic license, the synthetic option is not displayed.

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 8be679a)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 19, 2024
…200776)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Mappings Editor] Add support for synthetic _source
(#199854)](#199854)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-19T16:49:50Z","message":"[Mappings
Editor] Add support for synthetic _source (#199854)\n\nCloses
https://github.com/elastic/kibana/issues/198621\r\n\r\n##
Summary\r\n\r\nThis PR adds support for the synthetic _source field in
the mappings\r\nAdvanced options.\r\n\r\nStored option:\r\n<img
width=\"1184\" alt=\"Screenshot 2024-11-14 at 19 19
19\"\r\nsrc=\"https://github.com/user-attachments/assets/086f7a3e-9ca1-42de-9f9c-d3599d839ccf\">\r\n\r\nSynthetic
option selected:\r\n<img width=\"1184\" alt=\"Screenshot 2024-11-14 at
19 19
27\"\r\nsrc=\"https://github.com/user-attachments/assets/3700bced-212a-4378-b51a-ab7a0f4f7b99\">\r\n\r\nDisabled
option selected:\r\n<img width=\"1184\" alt=\"Screenshot 2024-11-14 at
19 19
36\"\r\nsrc=\"https://github.com/user-attachments/assets/c7ddcbae-7c78-4477-824e-99b144a1f750\">\r\n\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/399d0f95-a5dd-4874-bb8c-e95d6ed38465\r\n\r\n\r\n\r\n\r\nHow
to test:\r\n1. Start Es with `yarn es snapshot --license` (we need
Enterprise\r\nlicense to see the Synthetic source option) and Kibana
with `yarn start`\r\n2. Go to Index templates/Component templates and
start creating a\r\ntemplate\r\n3. At the Mappings step, go to Advanced
options.\r\n4. Verify that selecting a _source field option translates
to the\r\ncorrect Es request.\r\n5. In Index templates form, verify that
the default _source option\r\ndepends on the index mode selected in the
Logistics step. For LogsDB and\r\nTime series index mode, the default
should be synthetic mode; otherwise,\r\nthe stored option.\r\n6. Verify
that in Basic license, the synthetic option is not
displayed.\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added
follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"8be679ae20fb7f5c41ccb3554b6db3dc2cad0678","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","Feature:Mappings
Editor","v9.0.0","backport:prev-minor","v8.17.0"],"title":"[Mappings
Editor] Add support for synthetic
_source","number":199854,"url":"https://github.com/elastic/kibana/pull/199854","mergeCommit":{"message":"[Mappings
Editor] Add support for synthetic _source (#199854)\n\nCloses
https://github.com/elastic/kibana/issues/198621\r\n\r\n##
Summary\r\n\r\nThis PR adds support for the synthetic _source field in
the mappings\r\nAdvanced options.\r\n\r\nStored option:\r\n<img
width=\"1184\" alt=\"Screenshot 2024-11-14 at 19 19
19\"\r\nsrc=\"https://github.com/user-attachments/assets/086f7a3e-9ca1-42de-9f9c-d3599d839ccf\">\r\n\r\nSynthetic
option selected:\r\n<img width=\"1184\" alt=\"Screenshot 2024-11-14 at
19 19
27\"\r\nsrc=\"https://github.com/user-attachments/assets/3700bced-212a-4378-b51a-ab7a0f4f7b99\">\r\n\r\nDisabled
option selected:\r\n<img width=\"1184\" alt=\"Screenshot 2024-11-14 at
19 19
36\"\r\nsrc=\"https://github.com/user-attachments/assets/c7ddcbae-7c78-4477-824e-99b144a1f750\">\r\n\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/399d0f95-a5dd-4874-bb8c-e95d6ed38465\r\n\r\n\r\n\r\n\r\nHow
to test:\r\n1. Start Es with `yarn es snapshot --license` (we need
Enterprise\r\nlicense to see the Synthetic source option) and Kibana
with `yarn start`\r\n2. Go to Index templates/Component templates and
start creating a\r\ntemplate\r\n3. At the Mappings step, go to Advanced
options.\r\n4. Verify that selecting a _source field option translates
to the\r\ncorrect Es request.\r\n5. In Index templates form, verify that
the default _source option\r\ndepends on the index mode selected in the
Logistics step. For LogsDB and\r\nTime series index mode, the default
should be synthetic mode; otherwise,\r\nthe stored option.\r\n6. Verify
that in Basic license, the synthetic option is not
displayed.\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added
follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"8be679ae20fb7f5c41ccb3554b6db3dc2cad0678"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199854","number":199854,"mergeCommit":{"message":"[Mappings
Editor] Add support for synthetic _source (#199854)\n\nCloses
https://github.com/elastic/kibana/issues/198621\r\n\r\n##
Summary\r\n\r\nThis PR adds support for the synthetic _source field in
the mappings\r\nAdvanced options.\r\n\r\nStored option:\r\n<img
width=\"1184\" alt=\"Screenshot 2024-11-14 at 19 19
19\"\r\nsrc=\"https://github.com/user-attachments/assets/086f7a3e-9ca1-42de-9f9c-d3599d839ccf\">\r\n\r\nSynthetic
option selected:\r\n<img width=\"1184\" alt=\"Screenshot 2024-11-14 at
19 19
27\"\r\nsrc=\"https://github.com/user-attachments/assets/3700bced-212a-4378-b51a-ab7a0f4f7b99\">\r\n\r\nDisabled
option selected:\r\n<img width=\"1184\" alt=\"Screenshot 2024-11-14 at
19 19
36\"\r\nsrc=\"https://github.com/user-attachments/assets/c7ddcbae-7c78-4477-824e-99b144a1f750\">\r\n\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/399d0f95-a5dd-4874-bb8c-e95d6ed38465\r\n\r\n\r\n\r\n\r\nHow
to test:\r\n1. Start Es with `yarn es snapshot --license` (we need
Enterprise\r\nlicense to see the Synthetic source option) and Kibana
with `yarn start`\r\n2. Go to Index templates/Component templates and
start creating a\r\ntemplate\r\n3. At the Mappings step, go to Advanced
options.\r\n4. Verify that selecting a _source field option translates
to the\r\ncorrect Es request.\r\n5. In Index templates form, verify that
the default _source option\r\ndepends on the index mode selected in the
Logistics step. For LogsDB and\r\nTime series index mode, the default
should be synthetic mode; otherwise,\r\nthe stored option.\r\n6. Verify
that in Basic license, the synthetic option is not
displayed.\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added
follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"8be679ae20fb7f5c41ccb3554b6db3dc2cad0678"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <[email protected]>
ElenaStoeva added a commit that referenced this pull request Nov 25, 2024
Closes #200769

## Summary

This PR is a follow-up to #199854
and it adds the following code improvements:

- Replaces Mappings-editor-context-level property `hasEnterpriceLicense`
with plugin-context-level `canUseSyntheticSource` property
- Adds jest tests to check if the synthetic option is correctly
displayed based on license
- Improves readability of serializer logic for the source field


**How to test:**
The same test instructions from
#199854 can be followed with a
focus on checking that the synthetic option is only available in
Enterprise license.
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 25, 2024
)

Closes elastic#200769

## Summary

This PR is a follow-up to elastic#199854
and it adds the following code improvements:

- Replaces Mappings-editor-context-level property `hasEnterpriceLicense`
with plugin-context-level `canUseSyntheticSource` property
- Adds jest tests to check if the synthetic option is correctly
displayed based on license
- Improves readability of serializer logic for the source field

**How to test:**
The same test instructions from
elastic#199854 can be followed with a
focus on checking that the synthetic option is only available in
Enterprise license.

(cherry picked from commit 762bb7f)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 25, 2024
)

Closes elastic#200769

## Summary

This PR is a follow-up to elastic#199854
and it adds the following code improvements:

- Replaces Mappings-editor-context-level property `hasEnterpriceLicense`
with plugin-context-level `canUseSyntheticSource` property
- Adds jest tests to check if the synthetic option is correctly
displayed based on license
- Improves readability of serializer logic for the source field

**How to test:**
The same test instructions from
elastic#199854 can be followed with a
focus on checking that the synthetic option is only available in
Enterprise license.

(cherry picked from commit 762bb7f)
kibanamachine added a commit that referenced this pull request Nov 25, 2024
…) (#201577)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Mappings editor] Add code improvements for source field
(#201188)](#201188)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-25T12:46:05Z","message":"[Mappings
editor] Add code improvements for source field (#201188)\n\nCloses
https://github.com/elastic/kibana/issues/200769\r\n\r\n##
Summary\r\n\r\nThis PR is a follow-up to
https://github.com/elastic/kibana/pull/199854\r\nand it adds the
following code improvements:\r\n\r\n- Replaces
Mappings-editor-context-level property `hasEnterpriceLicense`\r\nwith
plugin-context-level `canUseSyntheticSource` property\r\n- Adds jest
tests to check if the synthetic option is correctly\r\ndisplayed based
on license\r\n- Improves readability of serializer logic for the source
field\r\n\r\n\r\n**How to test:**\r\nThe same test instructions
from\r\nhttps://github.com//pull/199854 can be followed
with a\r\nfocus on checking that the synthetic option is only available
in\r\nEnterprise
license.","sha":"762bb7f59d1d980aa34358c62ae0ef53e81f726e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","Feature:Mappings
Editor","v9.0.0","backport:prev-minor","v8.17.0","v8.18.0"],"title":"[Mappings
editor] Add code improvements for source
field","number":201188,"url":"https://github.com/elastic/kibana/pull/201188","mergeCommit":{"message":"[Mappings
editor] Add code improvements for source field (#201188)\n\nCloses
https://github.com/elastic/kibana/issues/200769\r\n\r\n##
Summary\r\n\r\nThis PR is a follow-up to
https://github.com/elastic/kibana/pull/199854\r\nand it adds the
following code improvements:\r\n\r\n- Replaces
Mappings-editor-context-level property `hasEnterpriceLicense`\r\nwith
plugin-context-level `canUseSyntheticSource` property\r\n- Adds jest
tests to check if the synthetic option is correctly\r\ndisplayed based
on license\r\n- Improves readability of serializer logic for the source
field\r\n\r\n\r\n**How to test:**\r\nThe same test instructions
from\r\nhttps://github.com//pull/199854 can be followed
with a\r\nfocus on checking that the synthetic option is only available
in\r\nEnterprise
license.","sha":"762bb7f59d1d980aa34358c62ae0ef53e81f726e"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201188","number":201188,"mergeCommit":{"message":"[Mappings
editor] Add code improvements for source field (#201188)\n\nCloses
https://github.com/elastic/kibana/issues/200769\r\n\r\n##
Summary\r\n\r\nThis PR is a follow-up to
https://github.com/elastic/kibana/pull/199854\r\nand it adds the
following code improvements:\r\n\r\n- Replaces
Mappings-editor-context-level property `hasEnterpriceLicense`\r\nwith
plugin-context-level `canUseSyntheticSource` property\r\n- Adds jest
tests to check if the synthetic option is correctly\r\ndisplayed based
on license\r\n- Improves readability of serializer logic for the source
field\r\n\r\n\r\n**How to test:**\r\nThe same test instructions
from\r\nhttps://github.com//pull/199854 can be followed
with a\r\nfocus on checking that the synthetic option is only available
in\r\nEnterprise
license.","sha":"762bb7f59d1d980aa34358c62ae0ef53e81f726e"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <[email protected]>
kibanamachine added a commit that referenced this pull request Nov 25, 2024
) (#201576)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[Mappings editor] Add code improvements for source field
(#201188)](#201188)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-25T12:46:05Z","message":"[Mappings
editor] Add code improvements for source field (#201188)\n\nCloses
https://github.com/elastic/kibana/issues/200769\r\n\r\n##
Summary\r\n\r\nThis PR is a follow-up to
https://github.com/elastic/kibana/pull/199854\r\nand it adds the
following code improvements:\r\n\r\n- Replaces
Mappings-editor-context-level property `hasEnterpriceLicense`\r\nwith
plugin-context-level `canUseSyntheticSource` property\r\n- Adds jest
tests to check if the synthetic option is correctly\r\ndisplayed based
on license\r\n- Improves readability of serializer logic for the source
field\r\n\r\n\r\n**How to test:**\r\nThe same test instructions
from\r\nhttps://github.com//pull/199854 can be followed
with a\r\nfocus on checking that the synthetic option is only available
in\r\nEnterprise
license.","sha":"762bb7f59d1d980aa34358c62ae0ef53e81f726e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","Feature:Mappings
Editor","v9.0.0","backport:prev-minor","v8.17.0","v8.18.0"],"title":"[Mappings
editor] Add code improvements for source
field","number":201188,"url":"https://github.com/elastic/kibana/pull/201188","mergeCommit":{"message":"[Mappings
editor] Add code improvements for source field (#201188)\n\nCloses
https://github.com/elastic/kibana/issues/200769\r\n\r\n##
Summary\r\n\r\nThis PR is a follow-up to
https://github.com/elastic/kibana/pull/199854\r\nand it adds the
following code improvements:\r\n\r\n- Replaces
Mappings-editor-context-level property `hasEnterpriceLicense`\r\nwith
plugin-context-level `canUseSyntheticSource` property\r\n- Adds jest
tests to check if the synthetic option is correctly\r\ndisplayed based
on license\r\n- Improves readability of serializer logic for the source
field\r\n\r\n\r\n**How to test:**\r\nThe same test instructions
from\r\nhttps://github.com//pull/199854 can be followed
with a\r\nfocus on checking that the synthetic option is only available
in\r\nEnterprise
license.","sha":"762bb7f59d1d980aa34358c62ae0ef53e81f726e"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201188","number":201188,"mergeCommit":{"message":"[Mappings
editor] Add code improvements for source field (#201188)\n\nCloses
https://github.com/elastic/kibana/issues/200769\r\n\r\n##
Summary\r\n\r\nThis PR is a follow-up to
https://github.com/elastic/kibana/pull/199854\r\nand it adds the
following code improvements:\r\n\r\n- Replaces
Mappings-editor-context-level property `hasEnterpriceLicense`\r\nwith
plugin-context-level `canUseSyntheticSource` property\r\n- Adds jest
tests to check if the synthetic option is correctly\r\ndisplayed based
on license\r\n- Improves readability of serializer logic for the source
field\r\n\r\n\r\n**How to test:**\r\nThe same test instructions
from\r\nhttps://github.com//pull/199854 can be followed
with a\r\nfocus on checking that the synthetic option is only available
in\r\nEnterprise
license.","sha":"762bb7f59d1d980aa34358c62ae0ef53e81f726e"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <[email protected]>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
Closes elastic#198621

## Summary

This PR adds support for the synthetic _source field in the mappings
Advanced options.

Stored option:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 19"
src="https://github.com/user-attachments/assets/086f7a3e-9ca1-42de-9f9c-d3599d839ccf">

Synthetic option selected:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 27"
src="https://github.com/user-attachments/assets/3700bced-212a-4378-b51a-ab7a0f4f7b99">

Disabled option selected:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 36"
src="https://github.com/user-attachments/assets/c7ddcbae-7c78-4477-824e-99b144a1f750">




https://github.com/user-attachments/assets/399d0f95-a5dd-4874-bb8c-e95d6ed38465




How to test:
1. Start Es with `yarn es snapshot --license` (we need Enterprise
license to see the Synthetic source option) and Kibana with `yarn start`
2. Go to Index templates/Component templates and start creating a
template
3. At the Mappings step, go to Advanced options.
4. Verify that selecting a _source field option translates to the
correct Es request.
5. In Index templates form, verify that the default _source option
depends on the index mode selected in the Logistics step. For LogsDB and
Time series index mode, the default should be synthetic mode; otherwise,
the stored option.
6. Verify that in Basic license, the synthetic option is not displayed.



### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: kibanamachine <[email protected]>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
)

Closes elastic#200769

## Summary

This PR is a follow-up to elastic#199854
and it adds the following code improvements:

- Replaces Mappings-editor-context-level property `hasEnterpriceLicense`
with plugin-context-level `canUseSyntheticSource` property
- Adds jest tests to check if the synthetic option is correctly
displayed based on license
- Improves readability of serializer logic for the source field


**How to test:**
The same test instructions from
elastic#199854 can be followed with a
focus on checking that the synthetic option is only available in
Enterprise license.
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
Closes elastic#198621

## Summary

This PR adds support for the synthetic _source field in the mappings
Advanced options.

Stored option:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 19"
src="https://github.com/user-attachments/assets/086f7a3e-9ca1-42de-9f9c-d3599d839ccf">

Synthetic option selected:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 27"
src="https://github.com/user-attachments/assets/3700bced-212a-4378-b51a-ab7a0f4f7b99">

Disabled option selected:
<img width="1184" alt="Screenshot 2024-11-14 at 19 19 36"
src="https://github.com/user-attachments/assets/c7ddcbae-7c78-4477-824e-99b144a1f750">




https://github.com/user-attachments/assets/399d0f95-a5dd-4874-bb8c-e95d6ed38465




How to test:
1. Start Es with `yarn es snapshot --license` (we need Enterprise
license to see the Synthetic source option) and Kibana with `yarn start`
2. Go to Index templates/Component templates and start creating a
template
3. At the Mappings step, go to Advanced options.
4. Verify that selecting a _source field option translates to the
correct Es request.
5. In Index templates form, verify that the default _source option
depends on the index mode selected in the Logistics step. For LogsDB and
Time series index mode, the default should be synthetic mode; otherwise,
the stored option.
6. Verify that in Basic license, the synthetic option is not displayed.



### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: kibanamachine <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
)

Closes elastic#200769

## Summary

This PR is a follow-up to elastic#199854
and it adds the following code improvements:

- Replaces Mappings-editor-context-level property `hasEnterpriceLicense`
with plugin-context-level `canUseSyntheticSource` property
- Adds jest tests to check if the synthetic option is correctly
displayed based on license
- Improves readability of serializer logic for the source field


**How to test:**
The same test instructions from
elastic#199854 can be followed with a
focus on checking that the synthetic option is only available in
Enterprise license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Mappings Editor Index mappings editor UI release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Index Management] _source changes in index and component templates
5 participants