# How to build an es query from kibana filters in a kibana plugin

**URL:** <https://discuss.elastic.co/t/how-to-build-an-es-query-from-kibana-filters-in-a-kibana-plugin/232218>\
**Category:** Kibana\
**Created:** [May 12, 2020, 11:30am UTC](https://discuss.elastic.co/t/how-to-build-an-es-query-from-kibana-filters-in-a-kibana-plugin/232218 "2020-05-12T11:30:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranitg](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ranitg](https://discuss.elastic.co/u/ranitg)\
**Post date:** [May 12, 2020, 11:30am UTC](https://discuss.elastic.co/t/how-to-build-an-es-query-from-kibana-filters-in-a-kibana-plugin/232218/1 "2020-05-12T11:30:17Z")

</div>

Hi,

I'm writing a Kibana plugin. How can I create an ES request from the current filters. What classes do I need to import and use?

Thanks

---

<div class="post-metadata">

**Author:** ![cheiligers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheiligers/32/73114_2.png) [@cheiligers](https://discuss.elastic.co/u/cheiligers)\
**Post date:** [June 4, 2020, 7:05pm UTC](https://discuss.elastic.co/t/how-to-build-an-es-query-from-kibana-filters-in-a-kibana-plugin/232218/2 "2020-06-04T19:05:19Z")

</div>

Hi @ranitg, as with most things, it depends on the version you're building the plugin for. If it's the latest development version, you'll want to look into using the [`data` plugin](https://github.com/elastic/kibana/tree/master/src/plugins/data). The `data` plugin is what drives the global search bar in Kibana.  
The more general plugin developer guide is given in the [elastic docs](https://www.elastic.co/guide/en/kibana/current/plugin-development.html).  
Other than that, you could look into how other Kibana plugins (visualize, discover, dashboard etc) implement the filters. Good luck!

---

<div class="post-metadata">

**Author:** ![ranitg](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ranitg](https://discuss.elastic.co/u/ranitg)\
**Post date:** [June 7, 2020, 6:54am UTC](https://discuss.elastic.co/t/how-to-build-an-es-query-from-kibana-filters-in-a-kibana-plugin/232218/3 "2020-06-07T06:54:28Z")

</div>

Hi,  
I am using Kibana 7.6.2. I have already looked into the data plugin. My question is, is there any interface or public class/function that I can import and use in my plugin? (without implementing everything over again in my plugin). If there is, what is the import statement that I should include in my code?

Thanks,  
Ranit

---

<div class="post-metadata">

**Author:** ![cheiligers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheiligers/32/73114_2.png) [@cheiligers](https://discuss.elastic.co/u/cheiligers)\
**Post date:** [June 8, 2020, 2:52pm UTC](https://discuss.elastic.co/t/how-to-build-an-es-query-from-kibana-filters-in-a-kibana-plugin/232218/4 "2020-06-08T14:52:44Z")

</div>

I haven't worked with the data plugin for a while and would need to look into how it's implemented in other plugins. I recommend that's a way to start.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2020, 2:52pm UTC](https://discuss.elastic.co/t/how-to-build-an-es-query-from-kibana-filters-in-a-kibana-plugin/232218/5 "2020-07-06T14:52:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
