Skip to content

[One Discover] [Logs UX]Add support to disable highlighting for certain filters we deem internal#239402

Merged
achyutjhunjhunwala merged 20 commits into
elastic:mainfrom
achyutjhunjhunwala:add-support-for-hidden-filters-in-logs-overview-component
Nov 5, 2025
Merged

[One Discover] [Logs UX]Add support to disable highlighting for certain filters we deem internal#239402
achyutjhunjhunwala merged 20 commits into
elastic:mainfrom
achyutjhunjhunwala:add-support-for-hidden-filters-in-logs-overview-component

Conversation

@achyutjhunjhunwala
Copy link
Copy Markdown
Contributor

@achyutjhunjhunwala achyutjhunjhunwala commented Oct 16, 2025

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:

  • 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:

{
  "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)

image

After

image

Before (Host View)

image

After

image

After (Hosts Logs inside Flyout)

image

Before (Discover flyout for traces)

image

After

image

Logic Implemented for ?

  • APM Logs Page
  • All Host View
  • Host View inside Flyout
  • Discover Flyout for Traces

@achyutjhunjhunwala achyutjhunjhunwala self-assigned this Oct 16, 2025
@achyutjhunjhunwala achyutjhunjhunwala added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:obs-onboarding Observability Onboarding Team labels Oct 16, 2025
@achyutjhunjhunwala achyutjhunjhunwala marked this pull request as ready for review October 20, 2025 10:54
@achyutjhunjhunwala achyutjhunjhunwala requested a review from a team October 20, 2025 10:54
@achyutjhunjhunwala achyutjhunjhunwala requested review from a team as code owners October 20, 2025 10:54
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ux-logs-team (Team:obs-ux-logs)

Copy link
Copy Markdown
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Code review only. Left minor nit comment.

Comment thread src/platform/plugins/shared/data/common/search/search_source/search_source.ts Outdated
@botelastic botelastic Bot added the Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. label Oct 21, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@jennypavlova jennypavlova self-requested a review October 21, 2025 08:38
…earch_source.ts

Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
Copy link
Copy Markdown
Member

@jennypavlova jennypavlova left a comment

Choose a reason for hiding this comment

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

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
error

In this case, I would expect a validation around the search field or similar to what we have in the metadata tab.
image

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

@achyutjhunjhunwala
Copy link
Copy Markdown
Contributor Author

Can you please take a look?

@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

@achyutjhunjhunwala
Copy link
Copy Markdown
Contributor Author

achyutjhunjhunwala commented Oct 21, 2025

@crespocarlos @jennypavlova Thank you both for the detailed review. I have fixed most of them and added comments where required

Copy link
Copy Markdown
Contributor

@crespocarlos crespocarlos left a comment

Choose a reason for hiding this comment

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

LGTM. CR only. Thanks for the adjustments

Copy link
Copy Markdown
Contributor

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

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.

@achyutjhunjhunwala
Copy link
Copy Markdown
Contributor Author

@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.

"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."

isn't it more prone in the prop based approach rather than the meta based ?

The filter is

  • Optional, meaning false by default, meaning every filter would get highlighted by default on the Platform side
  • On the Consumer side, they simple need to add this flag to a filter they deem internal/hidden
Aspect Current: skipHighlight Metadata Proposed: highlightQuery Prop Result
User Visibility Metadata invisible in UI Prop invisible in UI SAME
User Control No UI to configure No UI to configure SAME
"Why isn't this filter highlighting?" Applicable Applicable
Code at consumer simple has to manage to props, easy to mix the filter causing undesired results
Responsibility Separation SearchSource handles filtering logic Consumer must handle filtering, now they only set a meta
--

I agree on the part unlike other props negate or disabled which are UI controllable, skipHighlight is not, but i don't find it as a strong reason to not add.

@lukasolson
Copy link
Copy Markdown
Contributor

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 filter.meta shape is, functionally, a storage-schema change that triggers migrations, bwc handling, export/import & validation considerations. Also, search source isn't the only consumer of filters, and we would need to check other consumers to make sure they properly handle this new skipHighlight parameter (e.g. kbn-es-query).

At its core, Filter.meta is really about filter pill behavior & identity. Using it to steer unrelated features (like highlight behavior) blurs separation of concerns and spreads app-specific semantics into global persisted state.

I would really like to push for adding something directly to SearchSource instead. Would it be acceptable to have something to the effect of searchSource.setHiddenFilters or searchSource.setNonHighlightingFilters instead? I can probably throw together a patch against your PR to give a better idea of how this might work if that's helpful. In this way we wouldn't be changing the external contract of Filter objects.

@achyutjhunjhunwala
Copy link
Copy Markdown
Contributor Author

@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 👍🏼

@iblancof
Copy link
Copy Markdown
Contributor

Great to see this added!

Do you think it would be possible to include this other component in the scope as well?

Screenshot 2025-10-27 at 12 09 01

If not, no worries!
I’ll take a look at how you implemented it, and once your PR is merged, I can create a follow-up to update it.

@achyutjhunjhunwala
Copy link
Copy Markdown
Contributor Author

@iblancof thank you pointing this out. I was not aware about this place. I will add it as part of my PR itself

@achyutjhunjhunwala
Copy link
Copy Markdown
Contributor Author

achyutjhunjhunwala commented Nov 4, 2025

@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 skipHighlight meta filter and moved the logic to props.

PR is ready for review again

Copy link
Copy Markdown
Contributor

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

Thanks for making these changes, this feels better! I just left some minor comments below about not typing nonHighlightingFilters as a function.

Comment thread src/platform/plugins/shared/data/common/search/search_source/search_source.ts Outdated
Comment thread src/platform/plugins/shared/data/common/search/search_source/types.ts Outdated
@achyutjhunjhunwala
Copy link
Copy Markdown
Contributor Author

@lukasolson Fixed the remaining ones here - ab173d5

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
apm 2.8MB 2.8MB +124.0B
fleet 2.1MB 2.1MB +66.0B
infra 1.1MB 1.1MB +1.2KB
logsShared 198.2KB 198.8KB +529.0B
unifiedDocViewer 274.0KB 274.0KB +15.0B
total +1.9KB

Page load bundle

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

id before after diff
data 433.2KB 433.9KB +678.0B
logsShared 90.0KB 90.6KB +585.0B
total +1.2KB
Unknown metric groups

API count

id before after diff
@kbn/saved-search-component 16 17 +1
data 3208 3210 +2
total +3

History

cc @achyutjhunjhunwala

@achyutjhunjhunwala achyutjhunjhunwala merged commit 7729e12 into elastic:main Nov 5, 2025
12 checks passed
@achyutjhunjhunwala achyutjhunjhunwala deleted the add-support-for-hidden-filters-in-logs-overview-component branch November 5, 2025 16:21
wildemat pushed a commit to wildemat/kibana that referenced this pull request Nov 5, 2025
…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>
viduni94 pushed a commit to viduni94/kibana that referenced this pull request Nov 5, 2025
…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>
eokoneyo pushed a commit to eokoneyo/kibana that referenced this pull request Dec 2, 2025
…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>
iblancof added a commit that referenced this pull request Apr 20, 2026
…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.
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 20, 2026
…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)
kibanamachine added a commit that referenced this pull request Apr 21, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:obs-onboarding Observability Onboarding Team Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discover] Make highlighting configurable in SavedSearchComponent

9 participants