# Wrong number of docs in elasticsearch

**URL:** <https://discuss.elastic.co/t/wrong-number-of-docs-in-elasticsearch/126096>\
**Category:** Elasticsearch\
**Created:** [March 29, 2018, 1:22pm UTC](https://discuss.elastic.co/t/wrong-number-of-docs-in-elasticsearch/126096 "2018-03-29T13:22:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliyesami](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@aliyesami](https://discuss.elastic.co/u/aliyesami)\
**Post date:** [March 29, 2018, 1:22pm UTC](https://discuss.elastic.co/t/wrong-number-of-docs-in-elasticsearch/126096/1 "2018-03-29T13:22:18Z")

</div>

i created an external hive table with EsStorageHandler and then inserted from a large table (61 million rows) into it , but when I look at the index its only giving me 216368692 docs?

> CREATE EXTERNAL TABLE test\_orc\_es (  
> acct\_num BIGINT,  
> pur\_id BIGINT,  
> pur\_det\_id BIGINT,  
> product\_pur\_product\_code STRING,  
> prod\_amt FLOAT,  
> pur\_trans\_date TIMESTAMP,  
> accttype\_acct\_type\_code STRING,  
> acctstat\_acct\_status\_code STRING,  
> emp\_emp\_code STRING,  
> plaza\_plaza\_id STRING,  
> purstat\_pur\_status\_code STRING  
> )  
> STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'  
> TBLPROPERTIES('es.resource' = 'purchase/purchase\_acct','es.nodes' = 'hadoop1:9200');

> hive\> insert overwrite table test\_orc\_es select acct\_num,pur\_id,pur\_det\_id,product\_pur\_product\_code,prod\_amt,pur\_trans\_date,accttype\_acct\_type\_code,acctstat\_acct\_status\_code,emp\_emp\_code,plaza\_plaza\_id,purstat\_pur\_status\_code FROM test\_orc\_txn;

> [hdfs@hadoop1 ~]$ curl 'hadoop1:9200/\_cat/indices?v'  
> health status index uuid pri rep docs.count docs.deleted store.size pri.store.size  
> green open purchase LgPZQ8D6RZC4Z2O1qobiIQ 5 1 216368692 0 52.1gb 26gb

> hive\> select count(\*) from test\_orc\_txn;  
> OK  
> 61429218

---

<div class="post-metadata">

**Author:** ![aliyesami](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@aliyesami](https://discuss.elastic.co/u/aliyesami)\
**Post date:** [March 29, 2018, 3:00pm UTC](https://discuss.elastic.co/t/wrong-number-of-docs-in-elasticsearch/126096/2 "2018-03-29T15:00:10Z")

</div>

I narrowed the issue to type of table being copied from. if I copy the data from external ORC table then all the rows match the ES document count but if I copy the data from a bucketed Transactional table then the documents don't match the table row count.

---

<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:** [April 26, 2018, 3:00pm UTC](https://discuss.elastic.co/t/wrong-number-of-docs-in-elasticsearch/126096/3 "2018-04-26T15:00:15Z")

</div>

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