# Random indexing

**URL:** <https://discuss.elastic.co/t/random-indexing/214876>\
**Category:** Elasticsearch\
**Created:** [January 13, 2020, 4:41pm UTC](https://discuss.elastic.co/t/random-indexing/214876 "2020-01-13T16:41:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shankarana](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@shankarana](https://discuss.elastic.co/u/shankarana)\
**Post date:** [January 13, 2020, 4:41pm UTC](https://discuss.elastic.co/t/random-indexing/214876/1 "2020-01-13T16:41:04Z")

</div>

Hi Team,  
My usecase to update index whenever the new json document received.  
Logstash will receive event and update ES index.  
example:  
01.00 AM:  
index name: currencies  
inserted with 5 documents  
**source-destination-offer%**  
USD - GBP- 2%  
USD - EUR - 2%  
USD - YEN - 3%  
GBP - USD - 0.2%  
EUR - USD - 0.2%

note: here we have only 3 documents for source=USD

next at 01.10 AM:  
index name: currencies  
only received 6 rows.  
**source-destination-offer%**  
USD GBP 10%  
USD EUR 10%  
USD YEN 10%  
USD JPY 10%  
USD CNY 10%

expected: i want to delete all old USD documents only and inserted newly received 5 USD + retain existing 2 non USD data

I am not having fixed interval re-indexing - which means - there is no time specific indexing job, as long as data come in (irrelevant interval ) to elastic search i need to start indexing it and make it available for consumer search in that case i would like to only replace the existing document which is impacted. do i need to handle using primary key concepts ?

---

<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:** [January 13, 2020, 5:58pm UTC](https://discuss.elastic.co/t/random-indexing/214876/2 "2020-01-13T17:58:37Z")

</div>

Welcome!

Why not using `USDEUR` as the document `_id`? So you will just replace the existing values or insert new ones if not yet existing.

---

<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:** [February 10, 2020, 5:58pm UTC](https://discuss.elastic.co/t/random-indexing/214876/3 "2020-02-10T17:58:41Z")

</div>

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