# Aggregation contains old values

**URL:** <https://discuss.elastic.co/t/aggregation-contains-old-values/369805>\
**Category:** Elasticsearch\
**Created:** [October 30, 2024, 10:47am UTC](https://discuss.elastic.co/t/aggregation-contains-old-values/369805 "2024-10-30T10:47:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhavyagc](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@Bhavyagc](https://discuss.elastic.co/u/Bhavyagc)\
**Post date:** [October 30, 2024, 10:47am UTC](https://discuss.elastic.co/t/aggregation-contains-old-values/369805/1 "2024-10-30T10:47:57Z")

</div>

Can someone please help on the below request?

Please find the below example and the exact issue I am facing....

I'm having some problems with aggregations returning old data. When I query directly using `bool/must/term` the data is not there - as it should. Only in aggregation results.

1. I have a property called `foo`.
2. Then I updated all the documents where `foo` had the value from `x` to `y`.

Querying directly for `foo` = `x` yields 0 results (Old value) and `foo` = `y` yields 10 results (New value)

When aggregating `foo` I receive `x` in the `foo` property (with `doc_count`=`0`) and `y` in the `foo` property (with `doc_count`=`10`, which seems correct) . why still **x** is appearing in **foo** property with zero doc count?

Elasticsearch version `8.15` running in Elastic Cloud.

Note: when I removed the index completely and populated the index again, everything was working as it should. It only appears to be happening on existing indices.

---

<div class="post-metadata">

**Author:** ![Bhavyagc](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@Bhavyagc](https://discuss.elastic.co/u/Bhavyagc)\
**Post date:** [October 30, 2024, 10:48am UTC](https://discuss.elastic.co/t/aggregation-contains-old-values/369805/2 "2024-10-30T10:48:50Z")

</div>

Removed #elastic-cloud

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [October 31, 2024, 6:30am UTC](https://discuss.elastic.co/t/aggregation-contains-old-values/369805/3 "2024-10-31T06:30:26Z")

</div>

As per [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-shard-min-doc-count) this is possible, in particular:

```auto
Setting min_doc_count=0 will also return buckets for terms that didn’t match
any hit. However, some of the returned terms which have a document count 
of zero might only belong to deleted documents or documents from other
types, so there is no warranty that a match_all query would find a positive 
document count for those terms.

```
