# Incorrect/increasing elasticsearch count query after re-indexing!

**URL:** <https://discuss.elastic.co/t/incorrect-increasing-elasticsearch-count-query-after-re-indexing/293096>\
**Category:** Elasticsearch\
**Created:** [December 29, 2021, 9:16am UTC](https://discuss.elastic.co/t/incorrect-increasing-elasticsearch-count-query-after-re-indexing/293096 "2021-12-29T09:16:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilia/32/60042_2.png) [@Ilia](https://discuss.elastic.co/u/Ilia)\
**Post date:** [December 29, 2021, 9:16am UTC](https://discuss.elastic.co/t/incorrect-increasing-elasticsearch-count-query-after-re-indexing/293096/1 "2021-12-29T09:16:11Z")

</div>

Some hours ago I've re-indexed one of my indices. The re-indexing process completed in about 2 hours and I've run the following query afterwards:

```auto
GET myIndex/_count
{
  "query": {
    "bool": {
      "must": [
        {
          "exists": {
            "field": "productDefinitionKey.confidence"
          }
        }
      ]
    }
  }
}

```

The problem is that the result of this count query was about 6,000 but it must be about 2,000,000! I've checked multiple documents and seen all have the `productDefinitionKey.confidence` field. Now, after about 20 hours, the result of this query is about 100,000 and is increasing. I guess something is running in background but I don't know what! I've searched a lot and asked from my Elasticsearch geek friends but couldn't know what caused the problem and what is happening.

One of my colleagues said something about checking ingest nodes and proposed to check system resources. I did dot that but I guess resources are not the problem.  
The below screenshots captured from `elasticsearch vue`, `htop` and `nmon`:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/f/0f21bb029c40c34de569ca1e3193c88b8352845a.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/7/67899124bc3cf7a19178b7b3dfa56d32fcb66895.jpeg)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/4/c4e25a47d95aac60e9feaaf007562ca5f5631041.jpeg)

---

<div class="post-metadata">

**Author:** ![Ilia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilia/32/60042_2.png) [@Ilia](https://discuss.elastic.co/u/Ilia)\
**Post date:** [December 29, 2021, 9:44am UTC](https://discuss.elastic.co/t/incorrect-increasing-elasticsearch-count-query-after-re-indexing/293096/2 "2021-12-29T09:44:06Z")

</div>

Right now we understand the problem. The field we searched for it, i.e. `productDefinitionKey.confidence` was not in index template but after re-indexing one of our remote colleagues changed the index mapping and added mapping for this new field! I guess he did do that immediately after re-indexing was completed and run his code to add new field into existing docs.

So the count number we saw was the count of docs that his code updated and all of added fields by re-indexing gone just to `_source` and hadn't been indexed! Because we set `dynamic` to `false` in the template beforehand.

---

<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:** [January 26, 2022, 9:44am UTC](https://discuss.elastic.co/t/incorrect-increasing-elasticsearch-count-query-after-re-indexing/293096/3 "2022-01-26T09:44:24Z")

</div>

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