# Is it possible to index data partially and don't loose current data?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-index-data-partially-and-dont-loose-current-data/29549>\
**Category:** Elasticsearch\
**Created:** [September 18, 2015, 8:04am UTC](https://discuss.elastic.co/t/is-it-possible-to-index-data-partially-and-dont-loose-current-data/29549 "2015-09-18T08:04:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhmtnlr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhmtnlr/32/45665_2.png) [@mhmtnlr](https://discuss.elastic.co/u/mhmtnlr)\
**Post date:** [September 18, 2015, 8:04am UTC](https://discuss.elastic.co/t/is-it-possible-to-index-data-partially-and-dont-loose-current-data/29549/1 "2015-09-18T08:04:46Z")

</div>

Hi,  
In my index, i have field which is optional. So, while i am indexing, i don't index this field. If it required then i add this field with update. This work just fine for me but problem is if i need to reindex that doc, i loose optional field.  
Let me explain it with an example;

let's say i index this,

```
{
    "id":"123"
    "user":"xyz",
    "message":"sample message"
}

```

then an update request came:

```
{
    "id":"123"
    "user":"xyz",
    "message":"sample message"
    "optional_field":"some data"
}

```

then when an reindex request came for this id, it became like this

```
  {
        "id":"123"
        "user":"xyz",
        "message":"updated sample message"
  }

```

i look at upsert in order to if doc is exist then update id, user and message field only but with upsert i couldn't use version control.  
I can't put optional field to index definition because then i have to set some default value when i am indexing and if doc is already exist then it will override it

So, i am wondering if it is possible to index data partially, so i wouldn't loose optional field.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 19, 2015, 1:45am UTC](https://discuss.elastic.co/t/is-it-possible-to-index-data-partially-and-dont-loose-current-data/29549/2 "2015-09-19T01:45:55Z")

</div>

Have you seen [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#\_updates\_with\_a\_partial\_document](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_updates_with_a_partial_document)?

---

<div class="post-metadata">

**Author:** ![mhmtnlr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhmtnlr/32/45665_2.png) [@mhmtnlr](https://discuss.elastic.co/u/mhmtnlr)\
**Post date:** [September 20, 2015, 7:06pm UTC](https://discuss.elastic.co/t/is-it-possible-to-index-data-partially-and-dont-loose-current-data/29549/3 "2015-09-20T19:06:03Z")

</div>

Yeah, i check that but it's not what i am looking for.  
I looking for partially indexing.  
I mean if doc not exist then create it,  
if doc exist then only update only given field (or merge whole exist data with new data end then index)  
As i said i check upsert but it doesn't have version control.

---

<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 5, 2017, 11:49pm UTC](https://discuss.elastic.co/t/is-it-possible-to-index-data-partially-and-dont-loose-current-data/29549/4 "2017-07-05T23:49:11Z")

</div>


