# Wrong doc\_count in term\_vectors?

**URL:** https://discuss.elastic.co/t/wrong-doc-count-in-term-vectors/255440
**Category:** Elasticsearch
**Created:** [November 15, 2020, 2:58pm UTC](https://discuss.elastic.co/t/wrong-doc-count-in-term-vectors/255440 "2020-11-15T14:58:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![flm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flm/32/3169_2.png) [@flm](https://discuss.elastic.co/u/flm)
#### Post date: [November 15, 2020, 2:58pm UTC](https://discuss.elastic.co/t/wrong-doc-count-in-term-vectors/255440/1 "2020-11-15T14:58:15Z")

</div>

`doc_count` is incremented when adding the same document several times.

To reproduce execute twice:

> ```
> PUT /test_index/_doc/1
> {
> "somefield": "somedata"
> }
> 
> ```

There is 1 document in the index but doc\_count=2:

> ```
> {
> "_index" : "test_index",
> "_type" : "_doc",
> "_id" : "1",
> "_version" : 2,
> "found" : true,
> "took" : 0,
> "term_vectors" : {
> "somefield" : {
> "field_statistics" : {
> "sum_doc_freq" : 2,
> "doc_count" : 2,
> "sum_ttf" : 2
> },
> "terms" : {
> "somedata" : {
> "term_freq" : 1,
> "tokens" : [
> {
> "position" : 0,
> "start_offset" : 0,
> "end_offset" : 8
> }
> ]
> }
> }
> }
> }
> }
> 
> ```

Is that expected?  
If for instance I compute TFIDF on terms for a document inserted several times (whatever the reason), this will be wrong.

---

<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: [December 13, 2020, 2:58pm UTC](https://discuss.elastic.co/t/wrong-doc-count-in-term-vectors/255440/2 "2020-12-13T14:58:24Z")

</div>

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