# Elasticsearch Indexing based on data input

**URL:** <https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795>\
**Category:** Elasticsearch\
**Created:** [April 20, 2020, 6:30am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795 "2020-04-20T06:30:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rampoq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rampoq/32/66650_2.png) [@rampoq](https://discuss.elastic.co/u/rampoq)\
**Post date:** [April 20, 2020, 6:30am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/1 "2020-04-20T06:30:46Z")

</div>

I wish to push documents in Json format and wish to update it based on the input data, to be specifiv like unique identifier present in data, ( if that unique identifier value is already present in indexed data, it should update the existing data with the upcoming updated data and if the data is not there then it should be inserted into the index ), i wish to customize the \_id metadata field is that possible in elasticsearch or do i have to customize anything for that

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 20, 2020, 6:42am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/2 "2020-04-20T06:42:54Z")

</div>

I'm not sure I understood all (an concrete example would help) but I don't think you can do that out of the box with elasticsearch.

---

<div class="post-metadata">

**Author:** ![rampoq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rampoq/32/66650_2.png) [@rampoq](https://discuss.elastic.co/u/rampoq)\
**Post date:** [April 20, 2020, 10:25am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/3 "2020-04-20T10:25:59Z")

</div>

thankyou is there any way of doing it with logstash filters based on the input data, as in case of beats, it identifies based on input data.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 20, 2020, 10:50am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/4 "2020-04-20T10:50:07Z")

</div>

As I said, I'm not sure to understand. A concrete example would help.

---

<div class="post-metadata">

**Author:** ![rampoq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rampoq/32/66650_2.png) [@rampoq](https://discuss.elastic.co/u/rampoq)\
**Post date:** [April 21, 2020, 6:39am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/5 "2020-04-21T06:39:35Z")

</div>

this is what i need, i have sample json data such as below which is going to be pushed to elasticsearch.  
sample data json:

```auto
{
	"phone":"9994825",
	"name":"raju",
	"client_id":"3"
}

```

updated post data:

```auto
{
	"phone":"9994825",
	"name":"raju",
	"address":"madurai",
	"client_id":"3",
	"city":"trichy"
}

```

uuid or doc id should be based on client\_id which is on my input data json, whenever i push this json with addedfields ( updated\_post\_data) or columns with same client\_id, the same document should be updated in elasticsearch. this is what i wish to do, it should not be inserted as new document inside the elasticsearch.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 22, 2020, 4:01pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/6 "2020-04-22T16:01:49Z")

</div>

Not sure I have the full picture. But you can do:

```auto
DELETE test
PUT test
PUT test/_doc/3
{
	"phone":"9994825",
	"name":"raju",
	"client_id":"3"
}
PUT test/_doc/3
{
	"phone":"9994825",
	"name":"raju",
	"address":"madurai",
	"client_id":"3",
	"city":"trichy"
}
GET test/_doc/3

```

---

<div class="post-metadata">

**Author:** ![rampoq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rampoq/32/66650_2.png) [@rampoq](https://discuss.elastic.co/u/rampoq)\
**Post date:** [April 23, 2020, 8:03am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/7 "2020-04-23T08:03:22Z")

</div>

Thanks @dadoonet, but i cant have control over the data posted url. i have to think any other way is there to perform this.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 23, 2020, 9:09am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/8 "2020-04-23T09:09:44Z")

</div>

I still don't understand the problem.

As I did it, could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<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:** [May 21, 2020, 9:09am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-based-on-data-input/228795/9 "2020-05-21T09:09:47Z")

</div>

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