-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Description
Some background:
When adding a visualization to the dashboard, we'd like to hide this visualization from the end user. From the end user perspective, this visualization doesn't exist in the Visualize app, but only in the context of the dashboard.
Plan:
To do that, I'd like to add a new flag to visualization saved object, called visible. All visualizations would have this flag set to true by default, except the ones created by the dashboard, which would have this set to false. If the flag is false, we wouldn't show this in the visualize listing. (Draft PR for the flow above)
Problem:
I thought that filtering items on the client side would be enough. This won't work in the saved objects management console, where we rely on the total number of hits in the ES response to do the pagination:
Line 226 in 7df981f
| filteredItemCount: resp.total, |
It could happen that ES finds 170 total saved objects, out of which 168 are visualizations, and out of those we only need to show 37, so the pagination would be messed up.
Which leads to changing the ES query itself. Query is issued through the saved_object_client.find method:
kibana/src/legacy/core_plugins/kibana/server/routes/api/management/saved_objects/find.js
Line 88 in 8e9a8a8
| const findResponse = await savedObjectsClient.find({ |
which transforms the options to simple_query_string and looks on specific fields (ie. title).
"must": [
{
"simple_query_string":
{
"query": "bla*" ,
"fields": ["config.title", "maps.title", "visualization.title"....]
}
}
]
Is there a way to make the saved object client accept any type of query?
I think the query I need would look something like:
{
"query": {
"bool": {
"must": {
"simple_query_string": {
"query": "bla*"
}
},
"should": [
{ "term": { "type": "visualization "}},
{ "term": { "type": "dashboard"}},
{ "term": { "type": "maps"}}
],
"must_not": {
"term": { "visualization.visible": "false" }
}
}
}
}
Alternatively, there's conditional clauses, but that can't be done through the client if I understand things correctly.
@pgayvallet suggest adding a visible field to all the saved objects as a mitigation for this issue, but it seems like an overkill for what I'm trying to do.
Would appreciate any ideas/thoughts/comments on how to proceed with this.