[One Discover] [Logs UX]Add support to disable highlighting for certain filters we deem internal#239402
Conversation
|
Pinging @elastic/obs-ux-logs-team (Team:obs-ux-logs) |
dej611
left a comment
There was a problem hiding this comment.
Code review only. Left minor nit comment.
|
Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services) |
…earch_source.ts Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
There was a problem hiding this comment.
Thanks for the highlighting changes! I tested on the host view, and if the user makes a typo, it crashes the whole page (The refresh button is not helping, and nothing works except leaving the app
hosts_logs_search.mov
In this case, I would expect a validation around the search field or similar to what we have in the metadata tab.

Can you please take a look?
Also, on the single host view, the page is not crashing, but I can only search using a string log. level: "info" won't work there (and if the string is "Error," for example, I see mixhighlighting - which I guess is expected)
host_logs_search.mov
@jennypavlova Good catch, i too saw that issue and fixed it in the flyout but completely forgot to replicate the change to the main hosts view |
|
@crespocarlos @jennypavlova Thank you both for the detailed review. I have fixed most of them and added comments where required |
crespocarlos
left a comment
There was a problem hiding this comment.
LGTM. CR only. Thanks for the adjustments
There was a problem hiding this comment.
I'm not a huge fan of including the skipHighlight in the filter meta, simply because this is more of a UX representation of the filter, and there's no way in the UX to configure skipHighlight. This means you could get into an odd situation where you have filters showing up and they're not highlighting as expected, and there's no indication how to fix this.
I did notice @davismcphee suggested here trying to use component props, and I'm curious if that approach was attempted, and if so, what was challenging or didn't work as expected. I think what would make more sense to me is if we added an additional highlightQuery prop to the SavedSearchComponent which allowed passing in DSL for the highlight query (or even the entire highlight configuration) and then used something like searchSource.setField('highlight', highlightProps) in the same place we're setting query and filters.
|
@lukasolson Thank you for the detailed review. I actually started with props and then moved to meta based approach because it was much cleaner and simpler against the prop based approach.
isn't it more prone in the prop based approach rather than the meta based ? The filter is
I agree on the part unlike other props |
|
In general I think we should avoid altering the filter metadata for a few reasons. It's stored directly in the URL and inside saved objects (saved searches, saved queries, dashboards, etc.). Any change to the serialized At its core, I would really like to push for adding something directly to |
|
@lukasolson Oh wow, in my hindsight i complete missed the bigger picture that indeed its a storage schema and could have cascading effects. I am on SDH duty this week and then Spacetime next week. So i will try what you suggested, and ping you once i am done. If its still something not ideal, i will ask you for the patch 👍🏼 |
|
Great to see this added! Do you think it would be possible to include this other component in the scope as well?
If not, no worries! |
|
@iblancof thank you pointing this out. I was not aware about this place. I will add it as part of my PR itself |
|
@iblancof I have added the support for the Traces Flyout in Discover, check the last commit here. Also updated the description with a screenshot @lukasolson I have changed the logic and removed the PR is ready for review again |
lukasolson
left a comment
There was a problem hiding this comment.
Thanks for making these changes, this feels better! I just left some minor comments below about not typing nonHighlightingFilters as a function.
|
@lukasolson Fixed the remaining ones here - ab173d5 |
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
Unknown metric groupsAPI count
History
|
…in filters we deem internal (elastic#239402) ## Summary closes elastic#234215 Implements selective filter highlighting to prevent context/internal filters from being highlighted in search results while still using them for document retrieval. ## Problem When using SavedSearchComponent with filters (e.g., filtering logs to `service.name: synth-node-0`), all filter matches are highlighted in yellow. This creates visual noise when filters are used for context rather than active search criteria. For example, in APM Service Logs: - Service name filter is used to scope the view but shouldn't be highlighted - User search filters should be highlighted to help locate matches Previously, there was no way to distinguish between these two types of filters. ## Solution This PR uses Elasticsearch's `highlight_query` parameter to control which filters trigger highlighting. The implementation adds a `skipHighlight` metadata field to filters. - Consumers mark filters with `skipHighlight: true` when creating them: - SearchSource builds two queries: 1. **Main query** - Uses all filters for document retrieval 2. **Highlight query** - Excludes filters with `skipHighlight: true` Example ES request: ```json { "query": { "bool": { "filter": [ { "term": { "service.name": "synth.node" } }, { "term": { "host.name": "instance" } } ] } }, "highlight": { "fields": { "*": {} }, "highlight_query": { "bool": { "filter": [ { "term": { "host.name": "instance" } } ] } } } } ``` Result: Documents are filtered by both conditions, but only "instance" is highlighted. ## Performance Impact The highlight_query parameter is processed by Elasticsearch on already-retrieved documents, so there's no additional data fetching or query execution overhead. ## Screenshots ### Before (APM) <img width="2280" height="1061" alt="image" src="https://github.com/user-attachments/assets/9a1cb62a-2252-443e-9c9c-46c49d301edc" /> ### After <img width="2294" height="1087" alt="image" src="https://github.com/user-attachments/assets/c800ae3c-3b4c-4b7d-bf09-04260d90db81" /> ### Before (Host View) <img width="1924" height="1055" alt="image" src="https://github.com/user-attachments/assets/7b758ffd-dd25-4a1b-8895-9f4941a671d5" /> ### After <img width="1958" height="1130" alt="image" src="https://github.com/user-attachments/assets/9aeff451-95ea-4f19-9177-60068dfd7aee" /> ### After (Hosts Logs inside Flyout) <img width="2296" height="1172" alt="image" src="https://github.com/user-attachments/assets/83a28a93-8dec-4708-b717-1c4966f93834" /> ### Before (Discover flyout for traces) <img width="1578" height="1138" alt="image" src="https://github.com/user-attachments/assets/9205d2bc-aeb7-4eda-af0a-35377862b45d" /> ### After <img width="1580" height="1175" alt="image" src="https://github.com/user-attachments/assets/063b4726-2a79-4cad-9755-0c51bacf234b" /> ## Logic Implemented for ? - APM Logs Page - All Host View - Host View inside Flyout - Discover Flyout for Traces --------- Co-authored-by: Marco Liberati <dej611@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…in filters we deem internal (elastic#239402) ## Summary closes elastic#234215 Implements selective filter highlighting to prevent context/internal filters from being highlighted in search results while still using them for document retrieval. ## Problem When using SavedSearchComponent with filters (e.g., filtering logs to `service.name: synth-node-0`), all filter matches are highlighted in yellow. This creates visual noise when filters are used for context rather than active search criteria. For example, in APM Service Logs: - Service name filter is used to scope the view but shouldn't be highlighted - User search filters should be highlighted to help locate matches Previously, there was no way to distinguish between these two types of filters. ## Solution This PR uses Elasticsearch's `highlight_query` parameter to control which filters trigger highlighting. The implementation adds a `skipHighlight` metadata field to filters. - Consumers mark filters with `skipHighlight: true` when creating them: - SearchSource builds two queries: 1. **Main query** - Uses all filters for document retrieval 2. **Highlight query** - Excludes filters with `skipHighlight: true` Example ES request: ```json { "query": { "bool": { "filter": [ { "term": { "service.name": "synth.node" } }, { "term": { "host.name": "instance" } } ] } }, "highlight": { "fields": { "*": {} }, "highlight_query": { "bool": { "filter": [ { "term": { "host.name": "instance" } } ] } } } } ``` Result: Documents are filtered by both conditions, but only "instance" is highlighted. ## Performance Impact The highlight_query parameter is processed by Elasticsearch on already-retrieved documents, so there's no additional data fetching or query execution overhead. ## Screenshots ### Before (APM) <img width="2280" height="1061" alt="image" src="https://github.com/user-attachments/assets/9a1cb62a-2252-443e-9c9c-46c49d301edc" /> ### After <img width="2294" height="1087" alt="image" src="https://github.com/user-attachments/assets/c800ae3c-3b4c-4b7d-bf09-04260d90db81" /> ### Before (Host View) <img width="1924" height="1055" alt="image" src="https://github.com/user-attachments/assets/7b758ffd-dd25-4a1b-8895-9f4941a671d5" /> ### After <img width="1958" height="1130" alt="image" src="https://github.com/user-attachments/assets/9aeff451-95ea-4f19-9177-60068dfd7aee" /> ### After (Hosts Logs inside Flyout) <img width="2296" height="1172" alt="image" src="https://github.com/user-attachments/assets/83a28a93-8dec-4708-b717-1c4966f93834" /> ### Before (Discover flyout for traces) <img width="1578" height="1138" alt="image" src="https://github.com/user-attachments/assets/9205d2bc-aeb7-4eda-af0a-35377862b45d" /> ### After <img width="1580" height="1175" alt="image" src="https://github.com/user-attachments/assets/063b4726-2a79-4cad-9755-0c51bacf234b" /> ## Logic Implemented for ? - APM Logs Page - All Host View - Host View inside Flyout - Discover Flyout for Traces --------- Co-authored-by: Marco Liberati <dej611@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…in filters we deem internal (elastic#239402) ## Summary closes elastic#234215 Implements selective filter highlighting to prevent context/internal filters from being highlighted in search results while still using them for document retrieval. ## Problem When using SavedSearchComponent with filters (e.g., filtering logs to `service.name: synth-node-0`), all filter matches are highlighted in yellow. This creates visual noise when filters are used for context rather than active search criteria. For example, in APM Service Logs: - Service name filter is used to scope the view but shouldn't be highlighted - User search filters should be highlighted to help locate matches Previously, there was no way to distinguish between these two types of filters. ## Solution This PR uses Elasticsearch's `highlight_query` parameter to control which filters trigger highlighting. The implementation adds a `skipHighlight` metadata field to filters. - Consumers mark filters with `skipHighlight: true` when creating them: - SearchSource builds two queries: 1. **Main query** - Uses all filters for document retrieval 2. **Highlight query** - Excludes filters with `skipHighlight: true` Example ES request: ```json { "query": { "bool": { "filter": [ { "term": { "service.name": "synth.node" } }, { "term": { "host.name": "instance" } } ] } }, "highlight": { "fields": { "*": {} }, "highlight_query": { "bool": { "filter": [ { "term": { "host.name": "instance" } } ] } } } } ``` Result: Documents are filtered by both conditions, but only "instance" is highlighted. ## Performance Impact The highlight_query parameter is processed by Elasticsearch on already-retrieved documents, so there's no additional data fetching or query execution overhead. ## Screenshots ### Before (APM) <img width="2280" height="1061" alt="image" src="https://github.com/user-attachments/assets/9a1cb62a-2252-443e-9c9c-46c49d301edc" /> ### After <img width="2294" height="1087" alt="image" src="https://github.com/user-attachments/assets/c800ae3c-3b4c-4b7d-bf09-04260d90db81" /> ### Before (Host View) <img width="1924" height="1055" alt="image" src="https://github.com/user-attachments/assets/7b758ffd-dd25-4a1b-8895-9f4941a671d5" /> ### After <img width="1958" height="1130" alt="image" src="https://github.com/user-attachments/assets/9aeff451-95ea-4f19-9177-60068dfd7aee" /> ### After (Hosts Logs inside Flyout) <img width="2296" height="1172" alt="image" src="https://github.com/user-attachments/assets/83a28a93-8dec-4708-b717-1c4966f93834" /> ### Before (Discover flyout for traces) <img width="1578" height="1138" alt="image" src="https://github.com/user-attachments/assets/9205d2bc-aeb7-4eda-af0a-35377862b45d" /> ### After <img width="1580" height="1175" alt="image" src="https://github.com/user-attachments/assets/063b4726-2a79-4cad-9755-0c51bacf234b" /> ## Logic Implemented for ? - APM Logs Page - All Host View - Host View inside Flyout - Discover Flyout for Traces --------- Co-authored-by: Marco Liberati <dej611@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…ialization (#261558) ## Summary Relates to #261234 `nonHighlightingFilters` was silently dropped during `fromStoredTab` / `toStoredTab` serialization in the Discover session embeddable as part of [[Discover Sessions as Code] Discover search embeddable: API schema, transforms, and feature flag](#255213). This caused the logs section in the traces flyout to run without the trace context filter (`trace.id`, `transaction.id`, `span.id`), returning all logs in the index instead of only the ones correlated to the opened trace document. |Before|After| |-|-| |<img width="1496" height="965" alt="Screenshot 2026-04-07 at 15 05 34" src="https://github.com/user-attachments/assets/9a1f21cd-3359-4753-b7d6-3bf1e3cef758" />|<img width="1495" height="965" alt="Screenshot 2026-04-07 at 15 03 34" src="https://github.com/user-attachments/assets/87fb9b18-6bef-49dd-94ec-a3eea1d895f8" />| `nonHighlightingFilters` was introduced in [[One Discover] [Logs UX]Add support to disable highlighting for certain filters we deem internal](#239402) to allow certain filters (trace context constraints) to be applied to the ES query without affecting result highlighting. The `fromStoredTab` / `toStoredTab` serialization round-trip was added later in [[Discover Sessions as Code] Discover search embeddable: API schema, transforms, and feature flag](#255213) and never included this field. ~~The fix ensures `nonHighlightingFilters` is read back from the serialized search source in `fromStoredTab` and written into `toStoredTab`, and adds the corresponding field to the server-side schema.~~ The fix avoids exposing `nonHighlightingFilters` as a public API schema field entirely. Since trace context filters are always runtime-derived from the opened document (`traceId`, `spanId`, `transactionId`), they never need to be persisted in the serialized state. The runtime prop path, `nonHighlightingQuery` → `createLogEventsRenderer` → `nonHighlightingFilters` on the initial searchSource, already handles the use case correctly on every mount. A `syncNonHighlightingFilters` effect has also been added to `SavedSearchComponentTable` as a defensive measure, consistent with how other dynamic props (`filters`, `query`, `timeRange`) are synced after mount. A defensive e2e test has been added: it opens the minimal trace flyout (2 correlated logs) and asserts the logs section shows exactly 2 results.
…ialization (elastic#261558) ## Summary Relates to elastic#261234 `nonHighlightingFilters` was silently dropped during `fromStoredTab` / `toStoredTab` serialization in the Discover session embeddable as part of [[Discover Sessions as Code] Discover search embeddable: API schema, transforms, and feature flag](elastic#255213). This caused the logs section in the traces flyout to run without the trace context filter (`trace.id`, `transaction.id`, `span.id`), returning all logs in the index instead of only the ones correlated to the opened trace document. |Before|After| |-|-| |<img width="1496" height="965" alt="Screenshot 2026-04-07 at 15 05 34" src="https://github.com/user-attachments/assets/9a1f21cd-3359-4753-b7d6-3bf1e3cef758" />|<img width="1495" height="965" alt="Screenshot 2026-04-07 at 15 03 34" src="https://github.com/user-attachments/assets/87fb9b18-6bef-49dd-94ec-a3eea1d895f8" />| `nonHighlightingFilters` was introduced in [[One Discover] [Logs UX]Add support to disable highlighting for certain filters we deem internal](elastic#239402) to allow certain filters (trace context constraints) to be applied to the ES query without affecting result highlighting. The `fromStoredTab` / `toStoredTab` serialization round-trip was added later in [[Discover Sessions as Code] Discover search embeddable: API schema, transforms, and feature flag](elastic#255213) and never included this field. ~~The fix ensures `nonHighlightingFilters` is read back from the serialized search source in `fromStoredTab` and written into `toStoredTab`, and adds the corresponding field to the server-side schema.~~ The fix avoids exposing `nonHighlightingFilters` as a public API schema field entirely. Since trace context filters are always runtime-derived from the opened document (`traceId`, `spanId`, `transactionId`), they never need to be persisted in the serialized state. The runtime prop path, `nonHighlightingQuery` → `createLogEventsRenderer` → `nonHighlightingFilters` on the initial searchSource, already handles the use case correctly on every mount. A `syncNonHighlightingFilters` effect has also been added to `SavedSearchComponentTable` as a defensive measure, consistent with how other dynamic props (`filters`, `query`, `timeRange`) are synced after mount. A defensive e2e test has been added: it opens the minimal trace flyout (2 correlated logs) and asserts the logs section shows exactly 2 results. (cherry picked from commit ca6f9ec)
…ab serialization (#261558) (#264345) # Backport This will backport the following commits from `main` to `9.4`: - [[Discover][Traces] Fix nonHighlightingFilters lost in session tab serialization (#261558)](#261558) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Irene Blanco","email":"irene.blanco@elastic.co"},"sourceCommit":{"committedDate":"2026-04-20T09:04:45Z","message":"[Discover][Traces] Fix nonHighlightingFilters lost in session tab serialization (#261558)\n\n## Summary\n\nRelates to https://github.com/elastic/kibana/issues/261234\n\n`nonHighlightingFilters` was silently dropped during `fromStoredTab` /\n`toStoredTab` serialization in the Discover session embeddable as part\nof [[Discover Sessions as Code] Discover search embeddable: API schema,\ntransforms, and feature\nflag](#255213). This caused the\nlogs section in the traces flyout to run without the trace context\nfilter (`trace.id`, `transaction.id`, `span.id`), returning all logs in\nthe index instead of only the ones correlated to the opened trace\ndocument.\n\n|Before|After|\n|-|-|\n|<img width=\"1496\" height=\"965\" alt=\"Screenshot 2026-04-07 at 15 05 34\"\nsrc=\"https://github.com/user-attachments/assets/9a1f21cd-3359-4753-b7d6-3bf1e3cef758\"\n/>|<img width=\"1495\" height=\"965\" alt=\"Screenshot 2026-04-07 at 15 03\n34\"\nsrc=\"https://github.com/user-attachments/assets/87fb9b18-6bef-49dd-94ec-a3eea1d895f8\"\n/>|\n\n`nonHighlightingFilters` was introduced in [[One Discover] [Logs UX]Add\nsupport to disable highlighting for certain filters we deem\ninternal](#239402) to allow\ncertain filters (trace context constraints) to be applied to the ES\nquery without affecting result highlighting. The `fromStoredTab` /\n`toStoredTab` serialization round-trip was added later in [[Discover\nSessions as Code] Discover search embeddable: API schema, transforms,\nand feature flag](#255213) and\nnever included this field.\n\n~~The fix ensures `nonHighlightingFilters` is read back from the\nserialized search source in `fromStoredTab` and written into\n`toStoredTab`, and adds the corresponding field to the server-side\nschema.~~\n\nThe fix avoids exposing `nonHighlightingFilters` as a public API schema\nfield entirely. Since trace context filters are always runtime-derived\nfrom the opened document (`traceId`, `spanId`, `transactionId`), they\nnever need to be persisted in the serialized state.\n\nThe runtime prop path, `nonHighlightingQuery` →\n`createLogEventsRenderer` → `nonHighlightingFilters` on the initial\nsearchSource, already handles the use case correctly on every mount.\n\nA `syncNonHighlightingFilters` effect has also been added to\n`SavedSearchComponentTable` as a defensive measure, consistent with how\nother dynamic props (`filters`, `query`, `timeRange`) are synced after\nmount.\n\nA defensive e2e test has been added: it opens the minimal trace flyout\n(2 correlated logs) and asserts the logs section shows exactly 2\nresults.","sha":"ca6f9ec3b2ab13572f5fe7144537cb232870f930","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","backport:version","Feature:Traces in Discover","Team:obs-exploration","v9.4.0","v9.5.0"],"title":"[Discover][Traces] Fix nonHighlightingFilters lost in session tab serialization","number":261558,"url":"https://github.com/elastic/kibana/pull/261558","mergeCommit":{"message":"[Discover][Traces] Fix nonHighlightingFilters lost in session tab serialization (#261558)\n\n## Summary\n\nRelates to https://github.com/elastic/kibana/issues/261234\n\n`nonHighlightingFilters` was silently dropped during `fromStoredTab` /\n`toStoredTab` serialization in the Discover session embeddable as part\nof [[Discover Sessions as Code] Discover search embeddable: API schema,\ntransforms, and feature\nflag](#255213). This caused the\nlogs section in the traces flyout to run without the trace context\nfilter (`trace.id`, `transaction.id`, `span.id`), returning all logs in\nthe index instead of only the ones correlated to the opened trace\ndocument.\n\n|Before|After|\n|-|-|\n|<img width=\"1496\" height=\"965\" alt=\"Screenshot 2026-04-07 at 15 05 34\"\nsrc=\"https://github.com/user-attachments/assets/9a1f21cd-3359-4753-b7d6-3bf1e3cef758\"\n/>|<img width=\"1495\" height=\"965\" alt=\"Screenshot 2026-04-07 at 15 03\n34\"\nsrc=\"https://github.com/user-attachments/assets/87fb9b18-6bef-49dd-94ec-a3eea1d895f8\"\n/>|\n\n`nonHighlightingFilters` was introduced in [[One Discover] [Logs UX]Add\nsupport to disable highlighting for certain filters we deem\ninternal](#239402) to allow\ncertain filters (trace context constraints) to be applied to the ES\nquery without affecting result highlighting. The `fromStoredTab` /\n`toStoredTab` serialization round-trip was added later in [[Discover\nSessions as Code] Discover search embeddable: API schema, transforms,\nand feature flag](#255213) and\nnever included this field.\n\n~~The fix ensures `nonHighlightingFilters` is read back from the\nserialized search source in `fromStoredTab` and written into\n`toStoredTab`, and adds the corresponding field to the server-side\nschema.~~\n\nThe fix avoids exposing `nonHighlightingFilters` as a public API schema\nfield entirely. Since trace context filters are always runtime-derived\nfrom the opened document (`traceId`, `spanId`, `transactionId`), they\nnever need to be persisted in the serialized state.\n\nThe runtime prop path, `nonHighlightingQuery` →\n`createLogEventsRenderer` → `nonHighlightingFilters` on the initial\nsearchSource, already handles the use case correctly on every mount.\n\nA `syncNonHighlightingFilters` effect has also been added to\n`SavedSearchComponentTable` as a defensive measure, consistent with how\nother dynamic props (`filters`, `query`, `timeRange`) are synced after\nmount.\n\nA defensive e2e test has been added: it opens the minimal trace flyout\n(2 correlated logs) and asserts the logs section shows exactly 2\nresults.","sha":"ca6f9ec3b2ab13572f5fe7144537cb232870f930"}},"sourceBranch":"main","suggestedTargetBranches":["9.4"],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/261558","number":261558,"mergeCommit":{"message":"[Discover][Traces] Fix nonHighlightingFilters lost in session tab serialization (#261558)\n\n## Summary\n\nRelates to https://github.com/elastic/kibana/issues/261234\n\n`nonHighlightingFilters` was silently dropped during `fromStoredTab` /\n`toStoredTab` serialization in the Discover session embeddable as part\nof [[Discover Sessions as Code] Discover search embeddable: API schema,\ntransforms, and feature\nflag](#255213). This caused the\nlogs section in the traces flyout to run without the trace context\nfilter (`trace.id`, `transaction.id`, `span.id`), returning all logs in\nthe index instead of only the ones correlated to the opened trace\ndocument.\n\n|Before|After|\n|-|-|\n|<img width=\"1496\" height=\"965\" alt=\"Screenshot 2026-04-07 at 15 05 34\"\nsrc=\"https://github.com/user-attachments/assets/9a1f21cd-3359-4753-b7d6-3bf1e3cef758\"\n/>|<img width=\"1495\" height=\"965\" alt=\"Screenshot 2026-04-07 at 15 03\n34\"\nsrc=\"https://github.com/user-attachments/assets/87fb9b18-6bef-49dd-94ec-a3eea1d895f8\"\n/>|\n\n`nonHighlightingFilters` was introduced in [[One Discover] [Logs UX]Add\nsupport to disable highlighting for certain filters we deem\ninternal](#239402) to allow\ncertain filters (trace context constraints) to be applied to the ES\nquery without affecting result highlighting. The `fromStoredTab` /\n`toStoredTab` serialization round-trip was added later in [[Discover\nSessions as Code] Discover search embeddable: API schema, transforms,\nand feature flag](#255213) and\nnever included this field.\n\n~~The fix ensures `nonHighlightingFilters` is read back from the\nserialized search source in `fromStoredTab` and written into\n`toStoredTab`, and adds the corresponding field to the server-side\nschema.~~\n\nThe fix avoids exposing `nonHighlightingFilters` as a public API schema\nfield entirely. Since trace context filters are always runtime-derived\nfrom the opened document (`traceId`, `spanId`, `transactionId`), they\nnever need to be persisted in the serialized state.\n\nThe runtime prop path, `nonHighlightingQuery` →\n`createLogEventsRenderer` → `nonHighlightingFilters` on the initial\nsearchSource, already handles the use case correctly on every mount.\n\nA `syncNonHighlightingFilters` effect has also been added to\n`SavedSearchComponentTable` as a defensive measure, consistent with how\nother dynamic props (`filters`, `query`, `timeRange`) are synced after\nmount.\n\nA defensive e2e test has been added: it opens the minimal trace flyout\n(2 correlated logs) and asserts the logs section shows exactly 2\nresults.","sha":"ca6f9ec3b2ab13572f5fe7144537cb232870f930"}}]}] BACKPORT--> Co-authored-by: Irene Blanco <irene.blanco@elastic.co>

Summary
closes #234215
Implements selective filter highlighting to prevent context/internal filters from being highlighted in search results while still using them for document retrieval.
Problem
When using SavedSearchComponent with filters (e.g., filtering logs to
service.name: synth-node-0), all filter matches are highlighted in yellow. This creates visual noise when filters are used for context rather than active search criteria.For example, in APM Service Logs:
Previously, there was no way to distinguish between these two types of filters.
Solution
This PR uses Elasticsearch's
highlight_queryparameter to control which filters trigger highlighting. The implementation adds askipHighlightmetadata field to filters.Consumers mark filters with
skipHighlight: truewhen creating them:SearchSource builds two queries:
skipHighlight: trueExample ES request:
{ "query": { "bool": { "filter": [ { "term": { "service.name": "synth.node" } }, { "term": { "host.name": "instance" } } ] } }, "highlight": { "fields": { "*": {} }, "highlight_query": { "bool": { "filter": [ { "term": { "host.name": "instance" } } ] } } } }Result: Documents are filtered by both conditions, but only "instance" is highlighted.
Performance Impact
The highlight_query parameter is processed by Elasticsearch on already-retrieved documents, so there's no additional data fetching or query execution overhead.
Screenshots
Before (APM)
After
Before (Host View)
After
After (Hosts Logs inside Flyout)
Before (Discover flyout for traces)
After
Logic Implemented for ?