# Search with multiple filters involved all the time

**URL:** https://discuss.elastic.co/t/search-with-multiple-filters-involved-all-the-time/287702
**Category:** Elasticsearch
**Created:** [October 26, 2021, 2:06pm UTC](https://discuss.elastic.co/t/search-with-multiple-filters-involved-all-the-time/287702 "2021-10-26T14:06:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![itokai](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@itokai](https://discuss.elastic.co/u/itokai)
#### Post date: [October 26, 2021, 2:06pm UTC](https://discuss.elastic.co/t/search-with-multiple-filters-involved-all-the-time/287702/1 "2021-10-26T14:06:39Z")

</div>

Hello,

1. Specific use-case is to optimize querying that includes many (approximately 50) constant search filters. These filters might change 1-2x per year. How to involve those filters optimally, is it just by appending same criteria block every time? Something like SQL VIEW is needed, I guess.

2. Within _filter_ clause of _bool_, how to involve OR/AND clauses? Found abandoned  
_filter-or/and-filters_ technique, is there a similar or even better approach nowdays?  
According to general theory, in case _\_score_ is irrelevant, performance is better when clauses are in _filter_ block rather than _must/should_.

Regards

PS.  
found couple related topics, but they're not clearly answered or outdated

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [October 26, 2021, 10:12pm UTC](https://discuss.elastic.co/t/search-with-multiple-filters-involved-all-the-time/287702/2 "2021-10-26T22:12:36Z")

</div>

You can use a filter on an index alias, that might be worth looking into.

---

<div class="post-metadata">

### Author: ![itokai](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@itokai](https://discuss.elastic.co/u/itokai)
#### Post date: [October 27, 2021, 9:59am UTC](https://discuss.elastic.co/t/search-with-multiple-filters-involved-all-the-time/287702/3 "2021-10-27T09:59:51Z")

</div>

Thanks warkolm,

_index alias with filter_ sounds appropriate.  
But than comes the 2nd question, how to involve picky _filters_? Filter would need to contain clauses like regular _bool_ query (specified above)

Regards

---

<div class="post-metadata">

### Author: ![itokai](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@itokai](https://discuss.elastic.co/u/itokai)
#### Post date: [October 28, 2021, 10:27am UTC](https://discuss.elastic.co/t/search-with-multiple-filters-involved-all-the-time/287702/4 "2021-10-28T10:27:11Z")

</div>

Looks like below works (just the Kibana auto-complete wasn't popping up these blocks, at least here). Unless there is better approach?  
[Filter Block](https://stackoverflow.com/questions/57392532/elasticsearch-how-to-write-an-or-clause-in-filter-context)

---

<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: [November 25, 2021, 10:28am UTC](https://discuss.elastic.co/t/search-with-multiple-filters-involved-all-the-time/287702/5 "2021-11-25T10:28:00Z")

</div>

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