# Docs count delay - docs added regularly, but docs count 0

**URL:** https://discuss.elastic.co/t/docs-count-delay-docs-added-regularly-but-docs-count-0/303740
**Category:** Elasticsearch
**Created:** [May 2, 2022, 11:09am UTC](https://discuss.elastic.co/t/docs-count-delay-docs-added-regularly-but-docs-count-0/303740 "2022-05-02T11:09:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jb79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jb79/32/61949_2.png) [@jb79](https://discuss.elastic.co/u/jb79)
#### Post date: [May 2, 2022, 11:09am UTC](https://discuss.elastic.co/t/docs-count-delay-docs-added-regularly-but-docs-count-0/303740/1 "2022-05-02T11:09:22Z")

</div>

Hi,

Docs added regularly, but the count (after all added) could be verified after several minutes :  
**Added docs ( @timestamp from logstash):**

 ![added_docs](https://us1.discourse-cdn.com/elastic/original/3X/9/4/9488487d79ff9ca0337a97d1005cedfc803e63e4.jpeg)

**Transport traffic**

 ![transport_traffic](https://us1.discourse-cdn.com/elastic/original/3X/5/0/5043bbc232461306be9488f733c6a1c3073f4776.jpeg)

**Indexing rate:**

 ![doc_index_rate](https://us1.discourse-cdn.com/elastic/original/3X/9/d/9d3d09da143c65b3c63bfa121fe307c444a352eb.jpeg)

**Docs count**

 ![docs_count](https://us1.discourse-cdn.com/elastic/original/3X/d/9/d95738359847a9b771c7033e1d78dd8ecab35142.jpeg)

Seems that sth wrong with indexing - couldn't however find neither error, nor suspicious log in Elasticsearch (all master,client, data nodes checked).

- No parallel docs deletions on that index during insertions.
- All docs are in 1 segment ("num\_committed\_segments" : 6 - with several docs in other segments from other indices).

```auto
      "shards" : {
        "0" : [
          {
            "routing" : {
              "state" : "STARTED",
              "primary" : true,
              "node" : "SwYLLQLhQJqSZJz4uQDcjw"
            },
            "num_committed_segments" : 6,
            "num_search_segments" : 6,
            "segments" : {
...
              },
              "_2" : {
                "generation" : 2,
                "num_docs" : 211097,
                "deleted_docs" : 0,
                "size_in_bytes" : 24433952,
                "memory_in_bytes" : 9796,
                "committed" : true,
                "search" : true,
                "version" : "8.7.0",
                "compound" : true,
                "attributes" : {
                  "Lucene87StoredFieldsFormat.mode" : "BEST_SPEED"
                }
...

```

**What could be the reason of such behaviour ?  
What can I check (nodes stat, metric, setting, disk I/O,... )?  
On grafana couldn't find anything suspicious - there's also as in the docs count picture above a docs pick visible**

**Elasticsearch details**

```auto
  "version" : {
    "number" : "7.10.2",
    "build_flavor" : "oss",
    "build_type" : "rpm",
    "build_date" : "2021-12-20T10:05:59.588364Z",
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },

```

**ES cluster :**

```auto
{
  "cluster_name" : "abc-elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 19,
  "number_of_data_nodes" : 10,
  "active_primary_shards" : 25,
  "active_shards" : 58,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

```

Thanks in advance!

---

<div class="post-metadata">

### Author: ![jb79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jb79/32/61949_2.png) [@jb79](https://discuss.elastic.co/u/jb79)
#### Post date: [May 5, 2022, 10:38am UTC](https://discuss.elastic.co/t/docs-count-delay-docs-added-regularly-but-docs-count-0/303740/2 "2022-05-05T10:38:35Z")

</div>

Another thing we observed was that sometimes **docs are loaded first to the replica shard** and then to the primary one... :

```auto
index shard prirep state docs store ip node
test-index-2022.04.29-000001 0 p STARTED 27242 3.4mb 192.168.23.12 elasticsearch-data-1
test-index-2022.04.29-000001 0 r STARTED 29241 4.1mb 192.168.25.29 elasticsearch-data-2

```

What's interesting _GET test-index/\_search_ returned docs, although before the /_\_count_ query returned 0. After /_\_search_ query, /_\_count_ starts returning \> 0 result.

---

<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 2, 2022, 10:39am UTC](https://discuss.elastic.co/t/docs-count-delay-docs-added-regularly-but-docs-count-0/303740/3 "2022-06-02T10:39:29Z")

</div>

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