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?
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.
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.
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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.