Mutate query in SearchBar from within plugin visualization

I would like to mutate the query in the SearchBar from within my Kibana 7.5 visualization. I'm able to add and remove filters using the queryFilter API, but can't find anything to mutate the query in SearchBar.

Currently using code like this to mutate filters:

import { start as data } from '../../../../../src/legacy/core_plugins/data/public/legacy';

data.filter.filterManager.getFilters();
data.filter.filterManager.setFilters();

Is there such an API exposed to set the query in the SearchBar as well?

Hello,

They way you're approaching it was what I came up with as well just now looking through the code. i.e using FilterManager > setFilters. If it's not possible, I also came across this issue which may be relevant.

Regards,
Aaron

That’s indeed how I add and modify filters right now, but how would one modify the query in the SearchBar/QueryBar? (The kquery/lucene search string)

I wrote an incredibly ugly hack to get the rison encoded app state from the url, insert my own query in the query field, encode it back again and then push it to document.location.href so my query shows up and gets applied.

It works, but if there's an official API for this that plugin visualizations can access that would be better.

I've quickly looked at it, but could not find either. @Liza_Katz is working on filters, she will be able to help you when she's back from holidays.

1 Like

That sounds great, thank you for taking a look :slight_smile:

Hey,

Unfortunately, this feature is still not available.
However, this is something that was discussed before and it is on the roadmap for the 7.x versions.

This is the link to the issue. You can follow it to get notified when it is available.

In the meantime, the hack you mentioned is the way to go.