-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Console] Add highlighting for painless language #202695
[Console] Add highlighting for painless language #202695
Conversation
Pinging @elastic/kibana-management (Team:Kibana Management) |
💚 Build Succeeded
Metrics [docs]Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
cc @ElenaStoeva |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Code review only
@@ -100,17 +107,22 @@ xjsonRules.json_root = [ | |||
matchToken('variable.template', /("\${\w+}")/), | |||
// @ts-expect-error include a rule to start sql highlighting | |||
buildSqlStartRule(), | |||
// @ts-expect-error include a rule to start sql highlighting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: shouldn't this comment be to start painless highlighting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Fixed with 18a2f1f. Thanks for the review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, lgtm!
Starting backport for target branches: 8.16, 8.17, 8.x https://github.com/elastic/kibana/actions/runs/12162195614 |
Closes elastic#201672 ## Summary This PR adds existing painless rules to the console language so that the painless scripts are correctly highlighted. We are adding a painless starting rule that matches a string `"*_script"`, `"inline"`, or `"source"`, followed by a triple quote, in order to prevent clashing with the existing rules for triple-quote strings. Example request with a script: ``` POST _ingest/pipeline/_simulate { "pipeline": { "processors": [ { "script": { "description": "Extract 'tags' from 'env' field", "lang": "painless", "source": """ String[] envSplit = ctx['env'].splitOnToken(params['delimiter']); ArrayList tags = new ArrayList(); tags.add(envSplit[params['position']].trim()); ctx['tags'] = tags; """, "params": { "delimiter": "-", "position": 1 } } } ] }, "docs": [ { "_source": { "env": "es01-prod" } } ] } ``` <img width="1049" alt="Screenshot 2024-12-03 at 12 02 52" src="https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2"> (cherry picked from commit 2fcd323)
Closes elastic#201672 ## Summary This PR adds existing painless rules to the console language so that the painless scripts are correctly highlighted. We are adding a painless starting rule that matches a string `"*_script"`, `"inline"`, or `"source"`, followed by a triple quote, in order to prevent clashing with the existing rules for triple-quote strings. Example request with a script: ``` POST _ingest/pipeline/_simulate { "pipeline": { "processors": [ { "script": { "description": "Extract 'tags' from 'env' field", "lang": "painless", "source": """ String[] envSplit = ctx['env'].splitOnToken(params['delimiter']); ArrayList tags = new ArrayList(); tags.add(envSplit[params['position']].trim()); ctx['tags'] = tags; """, "params": { "delimiter": "-", "position": 1 } } } ] }, "docs": [ { "_source": { "env": "es01-prod" } } ] } ``` <img width="1049" alt="Screenshot 2024-12-03 at 12 02 52" src="https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2"> (cherry picked from commit 2fcd323)
Closes elastic#201672 ## Summary This PR adds existing painless rules to the console language so that the painless scripts are correctly highlighted. We are adding a painless starting rule that matches a string `"*_script"`, `"inline"`, or `"source"`, followed by a triple quote, in order to prevent clashing with the existing rules for triple-quote strings. Example request with a script: ``` POST _ingest/pipeline/_simulate { "pipeline": { "processors": [ { "script": { "description": "Extract 'tags' from 'env' field", "lang": "painless", "source": """ String[] envSplit = ctx['env'].splitOnToken(params['delimiter']); ArrayList tags = new ArrayList(); tags.add(envSplit[params['position']].trim()); ctx['tags'] = tags; """, "params": { "delimiter": "-", "position": 1 } } } ] }, "docs": [ { "_source": { "env": "es01-prod" } } ] } ``` <img width="1049" alt="Screenshot 2024-12-03 at 12 02 52" src="https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2"> (cherry picked from commit 2fcd323)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…2953) # Backport This will backport the following commits from `main` to `8.x`: - [[Console] Add highlighting for painless language (#202695)](#202695) <!--- 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-12-04T14:48:16Z","message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana Management","release_note:skip","v9.0.0","backport:prev-minor","v8.16.0","v8.17.0"],"title":"[Console] Add highlighting for painless language","number":202695,"url":"https://github.com/elastic/kibana/pull/202695","mergeCommit":{"message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202695","number":202695,"mergeCommit":{"message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Elena Stoeva <[email protected]>
…02951) # Backport This will backport the following commits from `main` to `8.16`: - [[Console] Add highlighting for painless language (#202695)](#202695) <!--- 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-12-04T14:48:16Z","message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana Management","release_note:skip","v9.0.0","backport:prev-minor","v8.16.0","v8.17.0"],"title":"[Console] Add highlighting for painless language","number":202695,"url":"https://github.com/elastic/kibana/pull/202695","mergeCommit":{"message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202695","number":202695,"mergeCommit":{"message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Elena Stoeva <[email protected]>
…02952) # Backport This will backport the following commits from `main` to `8.17`: - [[Console] Add highlighting for painless language (#202695)](#202695) <!--- 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-12-04T14:48:16Z","message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana Management","release_note:skip","v9.0.0","backport:prev-minor","v8.16.0","v8.17.0"],"title":"[Console] Add highlighting for painless language","number":202695,"url":"https://github.com/elastic/kibana/pull/202695","mergeCommit":{"message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202695","number":202695,"mergeCommit":{"message":"[Console] Add highlighting for painless language (#202695)\n\nCloses https://github.com/elastic/kibana/issues/201672?reload=1?reload=1\r\n\r\n## Summary\r\n\r\nThis PR adds existing painless rules to the console language so that the\r\npainless scripts are correctly highlighted. We are adding a painless\r\nstarting rule that matches a string `\"*_script\"`, `\"inline\"`, or\r\n`\"source\"`, followed by a triple quote, in order to prevent clashing\r\nwith the existing rules for triple-quote strings.\r\n\r\nExample request with a script:\r\n\r\n```\r\nPOST _ingest/pipeline/_simulate\r\n{\r\n \"pipeline\": { \r\n \"processors\": [\r\n {\r\n \"script\": {\r\n \"description\": \"Extract 'tags' from 'env' field\",\r\n \"lang\": \"painless\",\r\n \"source\": \"\"\"\r\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\r\n ArrayList tags = new ArrayList();\r\n tags.add(envSplit[params['position']].trim());\r\n ctx['tags'] = tags;\r\n \"\"\",\r\n \"params\": {\r\n \"delimiter\": \"-\",\r\n \"position\": 1\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"docs\": [\r\n {\r\n \"_source\": {\r\n \"env\": \"es01-prod\"\r\n }\r\n }\r\n ]\r\n}\r\n```\r\n\r\n<img width=\"1049\" alt=\"Screenshot 2024-12-03 at 12 02 52\"\r\nsrc=\"https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2\">","sha":"2fcd323927e42b4e7648f2aaa1a38dd3c7ea3900"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Elena Stoeva <[email protected]>
Closes elastic#201672 ## Summary This PR adds existing painless rules to the console language so that the painless scripts are correctly highlighted. We are adding a painless starting rule that matches a string `"*_script"`, `"inline"`, or `"source"`, followed by a triple quote, in order to prevent clashing with the existing rules for triple-quote strings. Example request with a script: ``` POST _ingest/pipeline/_simulate { "pipeline": { "processors": [ { "script": { "description": "Extract 'tags' from 'env' field", "lang": "painless", "source": """ String[] envSplit = ctx['env'].splitOnToken(params['delimiter']); ArrayList tags = new ArrayList(); tags.add(envSplit[params['position']].trim()); ctx['tags'] = tags; """, "params": { "delimiter": "-", "position": 1 } } } ] }, "docs": [ { "_source": { "env": "es01-prod" } } ] } ``` <img width="1049" alt="Screenshot 2024-12-03 at 12 02 52" src="https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2">
Closes elastic#201672 ## Summary This PR adds existing painless rules to the console language so that the painless scripts are correctly highlighted. We are adding a painless starting rule that matches a string `"*_script"`, `"inline"`, or `"source"`, followed by a triple quote, in order to prevent clashing with the existing rules for triple-quote strings. Example request with a script: ``` POST _ingest/pipeline/_simulate { "pipeline": { "processors": [ { "script": { "description": "Extract 'tags' from 'env' field", "lang": "painless", "source": """ String[] envSplit = ctx['env'].splitOnToken(params['delimiter']); ArrayList tags = new ArrayList(); tags.add(envSplit[params['position']].trim()); ctx['tags'] = tags; """, "params": { "delimiter": "-", "position": 1 } } } ] }, "docs": [ { "_source": { "env": "es01-prod" } } ] } ``` <img width="1049" alt="Screenshot 2024-12-03 at 12 02 52" src="https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2">
Closes elastic#201672 ## Summary This PR adds existing painless rules to the console language so that the painless scripts are correctly highlighted. We are adding a painless starting rule that matches a string `"*_script"`, `"inline"`, or `"source"`, followed by a triple quote, in order to prevent clashing with the existing rules for triple-quote strings. Example request with a script: ``` POST _ingest/pipeline/_simulate { "pipeline": { "processors": [ { "script": { "description": "Extract 'tags' from 'env' field", "lang": "painless", "source": """ String[] envSplit = ctx['env'].splitOnToken(params['delimiter']); ArrayList tags = new ArrayList(); tags.add(envSplit[params['position']].trim()); ctx['tags'] = tags; """, "params": { "delimiter": "-", "position": 1 } } } ] }, "docs": [ { "_source": { "env": "es01-prod" } } ] } ``` <img width="1049" alt="Screenshot 2024-12-03 at 12 02 52" src="https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2">
Closes elastic#201672 ## Summary This PR adds existing painless rules to the console language so that the painless scripts are correctly highlighted. We are adding a painless starting rule that matches a string `"*_script"`, `"inline"`, or `"source"`, followed by a triple quote, in order to prevent clashing with the existing rules for triple-quote strings. Example request with a script: ``` POST _ingest/pipeline/_simulate { "pipeline": { "processors": [ { "script": { "description": "Extract 'tags' from 'env' field", "lang": "painless", "source": """ String[] envSplit = ctx['env'].splitOnToken(params['delimiter']); ArrayList tags = new ArrayList(); tags.add(envSplit[params['position']].trim()); ctx['tags'] = tags; """, "params": { "delimiter": "-", "position": 1 } } } ] }, "docs": [ { "_source": { "env": "es01-prod" } } ] } ``` <img width="1049" alt="Screenshot 2024-12-03 at 12 02 52" src="https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2">
Closes #201672
Summary
This PR adds existing painless rules to the console language so that the painless scripts are correctly highlighted. We are adding a painless starting rule that matches a string
"*_script"
,"inline"
, or"source"
, followed by a triple quote, in order to prevent clashing with the existing rules for triple-quote strings.Example request with a script: