Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Discover] Pinned filters are ignored when fetching results for a saved search via a custom link #171212

Closed
jughosta opened this issue Nov 14, 2023 · 3 comments · Fixed by #175814
Assignees
Labels
bug Fixes for quality problems that affect the customer experience :DataDiscovery/fix-it-week impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:needs-research This issue requires some research before it can be worked on or estimated regression Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.

Comments

@jughosta
Copy link
Contributor

Kibana version: at least in 8.11 and above

Description of the problem including expected versus actual behavior:
If a saved search includes filters and URL is manually constructed to include pinned filters then the pinned filters are ignored after opening the URL.

Steps to reproduce:

  1. Create a saved search with some filters and save it
  2. Create a new filter and pin it => Make note of the current Discover URL and copy it including _g=... and excluding _a=... param (example: http://localhost:5601/qzv/app/discover#/view/2f360f30-ea74-11eb-b4c6-3d2afc1cb389?_g=(filters:!(('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'90943e30-9a47-11e8-b64d-95841ca0b247',key:machine.os,negate:!f,params:(query:ios),type:phrase),query:(match_phrase:(machine.os:ios)))),refreshInterval:(pause:!t,value:60000),time:(from:now-30d%2Fd,to:now)))
  3. Visit the URL

Expected: both filters (pinned and from the saved search) are applied
Actual: only the saved search filter was used to fetch results

Screenshot 2023-11-14 at 16 12 54
@jughosta jughosta added the Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. label Nov 14, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@kertal kertal added bug Fixes for quality problems that affect the customer experience impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:needs-research This issue requires some research before it can be worked on or estimated labels Nov 23, 2023
@kertal kertal added impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. regression and removed impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. labels Jan 9, 2024
@kertal
Copy link
Member

kertal commented Jan 10, 2024

To check: https://github.com/elastic/kibana/blob/main/src/plugins/discover/public/application/main/services/load_saved_search.ts#L128-L132

@jughosta Yes, that's for sure the right file, but I think it's likely because of this code:

if (appState) {
if (savedSearchId && appState.index) {
// This is for the case appState is overwriting the loaded saved search data view
const savedSearchDataViewId = nextSavedSearch.searchSource.getField('index')?.id;
const stateDataView = await getStateDataView(params, {
services,
appState,
internalStateContainer,
savedSearch: nextSavedSearch,
});
const dataViewDifferentToAppState = stateDataView.id !== savedSearchDataViewId;
if (stateDataView && (dataViewDifferentToAppState || !savedSearchDataViewId)) {
nextSavedSearch.searchSource.setField('index', stateDataView);
}
}
nextSavedSearch = savedSearchContainer.update({
nextDataView: nextSavedSearch.searchSource.getField('index'),
nextState: appState,
});
}

Since appState is empty initially (no _a in URL), the saved search is not updated (at L84), and that's why the global filter isn't being applied at the initial loading of the saved search, and the data fetching is done without the global state

jughosta added a commit that referenced this issue Feb 8, 2024
- Closes #171212

## Summary

Discover ignored global filters when loading a saved search, because it
loads a saved search before it starts syncing with global URL state.
This PR does not change the order of events but it adds a manual sync
for global filters so they are included in search request anyway.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this issue Feb 15, 2024
…c#175814)

- Closes elastic#171212

## Summary

Discover ignored global filters when loading a saved search, because it
loads a saved search before it starts syncing with global URL state.
This PR does not change the order of events but it adds a manual sync
for global filters so they are included in search request anyway.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
fkanout pushed a commit to fkanout/kibana that referenced this issue Mar 4, 2024
…c#175814)

- Closes elastic#171212

## Summary

Discover ignored global filters when loading a saved search, because it
loads a saved search before it starts syncing with global URL state.
This PR does not change the order of events but it adds a manual sync
for global filters so they are included in search request anyway.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience :DataDiscovery/fix-it-week impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:needs-research This issue requires some research before it can be worked on or estimated regression Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants