# Can i apply a KQL query that works on all indices present?

**URL:** <https://discuss.elastic.co/t/can-i-apply-a-kql-query-that-works-on-all-indices-present/301008>\
**Category:** Kibana\
**Created:** [March 29, 2022, 8:54pm UTC](https://discuss.elastic.co/t/can-i-apply-a-kql-query-that-works-on-all-indices-present/301008 "2022-03-29T20:54:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Dominic\_Ramp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_dominic_ramp/32/103606_2.png) [@Matthew\_Dominic\_Ramp](https://discuss.elastic.co/u/Matthew_Dominic_Ramp)\
**Post date:** [March 29, 2022, 8:54pm UTC](https://discuss.elastic.co/t/can-i-apply-a-kql-query-that-works-on-all-indices-present/301008/1 "2022-03-29T20:54:36Z")

</div>

Scenario:

- I have a dashboard which displays info from two indices, a & b
- both a& b have a field (which acts as a primary key would in sql) called id
- i want to type into the search/query bar a filter that searches for documents in both indices that match to the desired id.

Would this be possible?

---

<div class="post-metadata">

**Author:** ![sholzhauer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sholzhauer/32/110282_2.png) [@sholzhauer](https://discuss.elastic.co/u/sholzhauer)\
**Post date:** [March 30, 2022, 6:51am UTC](https://discuss.elastic.co/t/can-i-apply-a-kql-query-that-works-on-all-indices-present/301008/2 "2022-03-30T06:51:48Z")

</div>

Yes, in general, this is possible. You would search for `id:"alpha"` and the dashboard would apply that filter to all elements (both indices).

Sometimes this doesn't work. This is usually due to mapping conflicts.

---

<div class="post-metadata">

**Author:** ![msanz-acclaro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/msanz-acclaro/32/103661_2.png) [@msanz-acclaro](https://discuss.elastic.co/u/msanz-acclaro)\
**Post date:** [March 30, 2022, 8:04am UTC](https://discuss.elastic.co/t/can-i-apply-a-kql-query-that-works-on-all-indices-present/301008/3 "2022-03-30T08:04:20Z")

</div>

yes, you can use any field in common between two or more indexes to filter the visualizations at a dashboard, and there is an additional option in the "Stack Management \> Advanced Settings" that allows you to ignore the filter if the field used is not present in the index that creates the visualization. By default it is disabled.

> ### Ignore filter(s)
> 
> This configuration enhances support for dashboards containing visualizations accessing dissimilar indexes. When disabled, all filters are applied to all visualizations. When enabled, filter(s) will be ignored for a visualization when the visualization's index does not contain the filtering field.

---

<div class="post-metadata">

**Author:** ![Matthew\_Dominic\_Ramp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_dominic_ramp/32/103606_2.png) [@Matthew\_Dominic\_Ramp](https://discuss.elastic.co/u/Matthew_Dominic_Ramp)\
**Post date:** [March 30, 2022, 4:12pm UTC](https://discuss.elastic.co/t/can-i-apply-a-kql-query-that-works-on-all-indices-present/301008/4 "2022-03-30T16:12:58Z")

</div>

Thank you for the replies. The problem was indeed a mapping conflict. The mapping for the field in both indices was different. They are now the same and it is working

---

<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:** [April 27, 2022, 4:13pm UTC](https://discuss.elastic.co/t/can-i-apply-a-kql-query-that-works-on-all-indices-present/301008/5 "2022-04-27T16:13:53Z")

</div>

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