Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.16] [Console] Add highlighting for painless language (elastic#202695…
…) (elastic#202951) # Backport This will backport the following commits from `main` to `8.16`: - [[Console] Add highlighting for painless language (elastic#202695)](elastic#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":"59341489+ElenaStoeva@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-12-04T14:48:16Z","message":"[Console] Add highlighting for painless language (elastic#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 (elastic#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 (elastic#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 <59341489+ElenaStoeva@users.noreply.github.com>
- Loading branch information