# Updating index through postgres

**URL:** <https://discuss.elastic.co/t/updating-index-through-postgres/83687>\
**Category:** Elasticsearch\
**Created:** [April 26, 2017, 11:37am UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687 "2017-04-26T11:37:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![harikrishnanv](https://avatars.discourse-cdn.com/v4/letter/h/73ab20/32.png) [@harikrishnanv](https://discuss.elastic.co/u/harikrishnanv)\
**Post date:** [April 26, 2017, 11:37am UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687/1 "2017-04-26T11:37:31Z")

</div>

HI..  
I'm using elasticsearch 2.4 with postgres DB as data source. I'm indexing data into elasticsearch through a view in my postgres DB. When a new record added into DB, its getting indexed properly and I'm able to search that in elasticsearch. But if I change any value in the existing record, its getting indexed again as a new document instead of updating the old [one.So](http://one.So) its being duplicated when search for the same.  
What will be the solution for this.?Can anyone help me out.?

---

<div class="post-metadata">

**Author:** ![\_markus](https://avatars.discourse-cdn.com/v4/letter/_/ecb155/32.png) [@\_markus](https://discuss.elastic.co/u/_markus)\
**Post date:** [April 26, 2017, 11:53am UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687/2 "2017-04-26T11:53:27Z")

</div>

If you use the postgres row id (you have a primary key?) as the ES `_id`, you shouldn't see duplicates.

---

<div class="post-metadata">

**Author:** ![harikrishnanv](https://avatars.discourse-cdn.com/v4/letter/h/73ab20/32.png) [@harikrishnanv](https://discuss.elastic.co/u/harikrishnanv)\
**Post date:** [April 26, 2017, 11:59am UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687/3 "2017-04-26T11:59:22Z")

</div>

Thank you..But how can I add it into '\_id'.I never tried this before. Thanks in Advance

---

<div class="post-metadata">

**Author:** ![\_markus](https://avatars.discourse-cdn.com/v4/letter/_/ecb155/32.png) [@\_markus](https://discuss.elastic.co/u/_markus)\
**Post date:** [April 26, 2017, 12:04pm UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687/4 "2017-04-26T12:04:42Z")

</div>

Please see [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-id-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-id-field.html) .

You are being sparse how you really index the data so without more information about your actual setup I'm unable to further assist.

---

<div class="post-metadata">

**Author:** ![harikrishnanv](https://avatars.discourse-cdn.com/v4/letter/h/73ab20/32.png) [@harikrishnanv](https://discuss.elastic.co/u/harikrishnanv)\
**Post date:** [April 26, 2017, 12:06pm UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687/5 "2017-04-26T12:06:00Z")

</div>

Thanks a lot..🙂

---

<div class="post-metadata">

**Author:** ![harikrishnanv](https://avatars.discourse-cdn.com/v4/letter/h/73ab20/32.png) [@harikrishnanv](https://discuss.elastic.co/u/harikrishnanv)\
**Post date:** [April 26, 2017, 1:48pm UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687/6 "2017-04-26T13:48:19Z")

</div>

Have tried to add my primary key in '\_id' but its not working. When I searched regarding this I got like \_id is no longer configurable since elasticsearch 2.0.  
So what can I do now.😕

---

<div class="post-metadata">

**Author:** ![\_markus](https://avatars.discourse-cdn.com/v4/letter/_/ecb155/32.png) [@\_markus](https://discuss.elastic.co/u/_markus)\
**Post date:** [April 26, 2017, 8:22pm UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687/7 "2017-04-26T20:22:07Z")

</div>

`_id` is exactly what I'm using in my code. Did you try to provide it explicit in your mapping? I don't think you need to do so. Just index the field `_id` and it should be fine (depending on how you actually do this, see below).

You still failed to disclose _any_ further helpful information. Even when you say "I searched... I got like" you fail to provide the reference (though I don't think you want "configurable id" anyway to your solution?).

Please, if you want to be helped: provide references, explain your approach in more detail, show maybe pseudo-code or indices or mapping or _anything_ so people can stop making guesswork for you.

---

<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 24, 2017, 8:34pm UTC](https://discuss.elastic.co/t/updating-index-through-postgres/83687/8 "2017-05-24T20:34:27Z")

</div>

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