# Reducing the deleted docs in the index stats

**URL:** <https://discuss.elastic.co/t/reducing-the-deleted-docs-in-the-index-stats/239431>\
**Category:** Elasticsearch\
**Created:** [July 1, 2020, 7:51am UTC](https://discuss.elastic.co/t/reducing-the-deleted-docs-in-the-index-stats/239431 "2020-07-01T07:51:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shinji\_kun](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@shinji\_kun](https://discuss.elastic.co/u/shinji_kun)\
**Post date:** [July 1, 2020, 7:51am UTC](https://discuss.elastic.co/t/reducing-the-deleted-docs-in-the-index-stats/239431/1 "2020-07-01T07:51:22Z")

</div>

Hello, i'm want to import CVE Entrys from a feed.  
The feed consists of several Files, which gets generate every hour.  
In each File is a list of CVE Entrys. Most of the newly generated CVE Entrys(JSON), will get enriched with data (like CPE, Advisories...). That means in the future a new file will be generated, which contains an already published CVE-Entry (just with new values in the fields).  
I used the Ids for the CVE Entrys as the "\_id" for elasticsearch.  
When i import all the files with a python tool, i get the following result in the index stats:  
 ![docs_count](https://us1.discourse-cdn.com/elastic/original/3X/7/7/7752ad8a9bc6101cdf1e972ef4fc4e7857347cdf.png)

When you add up, the (docs:count)+(docs:deleted) you get exactly the number of CVE-entrys that have been fetched. Which is reasonable because most of the CVE-Entrys are available 2 times in the feed.  
I want to reduce the number of docs:deleted .  
I Import the CVE-entrys with python by putting them in a bulk like this:

```auto
cve_bulk={
                "_op_type": "update",
                "_index": index,
                "_id": cve["vuln_id"],
                "doc_as_upsert": True,
                "doc":cve
        }

```

In Order to reduce the number of deleted docs, i wanted to change the bulk and add a script to it in case a CVE-Entry get fetched for the second time, so i only change the fields from which i know they could be changed and leave the other fields untouched. But after a bit of research i understood: since i'm using \_op\_type:"update" a new doc will be created and the old deleted.  
This brings me to my question: Is there anyway to change the values of fields of a certain doc without deleting the doc itself, so that in the stats i will get docs:deleted=0 ?  
If that's not possible could my current situation impose a performance issue ?

KInd Regards.

---

<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:** [July 29, 2020, 7:51am UTC](https://discuss.elastic.co/t/reducing-the-deleted-docs-in-the-index-stats/239431/2 "2020-07-29T07:51:35Z")

</div>

Closed on July 29, 2020, 7:51am UTC

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