# Filter in multiple docs

**URL:** <https://discuss.elastic.co/t/filter-in-multiple-docs/305741>\
**Category:** Kibana\
**Created:** [May 26, 2022, 5:43pm UTC](https://discuss.elastic.co/t/filter-in-multiple-docs/305741 "2022-05-26T17:43:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thiago\_Paiva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago_paiva/32/52326_2.png) [@Thiago\_Paiva](https://discuss.elastic.co/u/Thiago_Paiva)\
**Post date:** [May 26, 2022, 5:43pm UTC](https://discuss.elastic.co/t/filter-in-multiple-docs/305741/1 "2022-05-26T17:43:03Z")

</div>

Hi,

I have an index that has a tracking by ID. For each step that id pass writes a DOC to elastic. But I'm  
trying to make a filter that does the following validation.

It passed Step2 but did not pass at Step4.

Exemple:

ID: 123  
STEP: A

ID: 123  
STEP: B

ID:123  
STEP:D

Filter: STEP:B AND NOT EXIST DOC WITH STEP:C  
Return: ID: 123

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [May 28, 2022, 2:24pm UTC](https://discuss.elastic.co/t/filter-in-multiple-docs/305741/2 "2022-05-28T14:24:58Z")

</div>

It could be possible with [bucket selector aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html) over ID and STEP terms aggregation. Note the [max\_buckets limitation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket.html).

---

<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:** [June 25, 2022, 2:25pm UTC](https://discuss.elastic.co/t/filter-in-multiple-docs/305741/3 "2022-06-25T14:25:27Z")

</div>

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