# Insert if not exists

**URL:** <https://discuss.elastic.co/t/insert-if-not-exists/11875>\
**Category:** Elasticsearch\
**Created:** [May 8, 2013, 12:06pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875 "2013-05-08T12:06:00Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![subhankar\_biswas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subhankar_biswas/32/140090_2.png) [@subhankar\_biswas](https://discuss.elastic.co/u/subhankar_biswas)\
**Post date:** [May 8, 2013, 12:06pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/1 "2013-05-08T12:06:00Z")

</div>

hi,  
my use case is something like this: i m inserting some data using auto  
id generation. so in future i' don't know what the id it created.  
now if i have to  
insert some field in that doc, i have to search for previous fields and  
update that doc.  
i can do it using two queries search and if not exists then update.  
BUT my question is --\> is there any way i can do it in one  
query??????

thanks,  
subhankar

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [May 8, 2013, 12:35pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/2 "2013-05-08T12:35:13Z")

</div>

Just see  
Operation Type in [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/index_/)

HTH

Thanks  
Vineeth  
On Wed, May 8, 2013 at 5:36 PM, subhankar [neo20iitkgp@gmail.com](mailto:neo20iitkgp@gmail.com) wrote:

> hi,  
> my use case is something like this: i m inserting some data using auto  
> id generation. so in future i' don't know what the id it created.  
> now if i have to  
> insert some field in that doc, i have to search for previous fields and  
> update that doc.  
> i can do it using two queries search and if not exists then update.  
> BUT my question is --\> is there any way i can do it in one  
> query??????
> 
> thanks,  
> subhankar
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![subhankar\_biswas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subhankar_biswas/32/140090_2.png) [@subhankar\_biswas](https://discuss.elastic.co/u/subhankar_biswas)\
**Post date:** [May 8, 2013, 12:54pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/3 "2013-05-08T12:54:22Z")

</div>

hi vineeth,  
i m very new to ES. i saw that earlier.  
plz correct me if i am wrong. i think that is for index request. for  
update api how this will work. i have to combine the query and update api  
both.  
and i think [GitHub - yakaz/elasticsearch-action-updatebyquery: ElasticSearch Update By Query action plugin](https://github.com/yakaz/elasticsearch-action-updatebyquery) will  
satisfy the requirement. what do you think. can you please give me a small  
example ??

Thanks,  
subhankar

On Wednesday, 8 May 2013 18:05:13 UTC+5:30, Vineeth Mohan wrote:

> Just see  
> Operation Type in [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/index_/)
> 
> HTH
> 
> Thanks  
> Vineeth  
> On Wed, May 8, 2013 at 5:36 PM, subhankar \<[neo20...@gmail.com](mailto:neo20...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > hi,  
> > my use case is something like this: i m inserting some data using  
> > auto id generation. so in future i' don't know what the id it created.  
> > now if i have to  
> > insert some field in that doc, i have to search for previous fields and  
> > update that doc.  
> > i can do it using two queries search and if not exists then  
> > update.  
> > BUT my question is --\> is there any way i can do it in one  
> > query??????
> > 
> > thanks,  
> > subhankar
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [May 8, 2013, 1:21pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/4 "2013-05-08T13:21:40Z")

</div>

This plugin is to update all existing documents by query. So if the  
document does not exist , it wont do anything.  
I believe what you need is "UPDATE IF EXISTS" , "CREATE IF NOT EXISTS"  
AFAIK this cant be done in a single query (And hence not atomic)

Thanks  
Vineeth

On Wed, May 8, 2013 at 6:24 PM, subhankar [neo20iitkgp@gmail.com](mailto:neo20iitkgp@gmail.com) wrote:

> hi vineeth,  
> i m very new to ES. i saw that earlier.  
> plz correct me if i am wrong. i think that is for index request. for  
> update api how this will work. i have to combine the query and update api  
> both.  
> and i think  
> [GitHub - yakaz/elasticsearch-action-updatebyquery: ElasticSearch Update By Query action plugin](https://github.com/yakaz/elasticsearch-action-updatebyquery) will satisfy  
> the requirement. what do you think. can you please give me a small example  
> ??
> 
> Thanks,  
> subhankar
> 
> On Wednesday, 8 May 2013 18:05:13 UTC+5:30, Vineeth Mohan wrote:
> 
> > Just see  
> > Operation Type in [http://www.elasticsearch.org/](http://www.elasticsearch.org/)\*\*  
> > guide/reference/api/index\_/[http://www.elasticsearch.org/guide/reference/api/index\_/](http://www.elasticsearch.org/guide/reference/api/index_/)
> > 
> > HTH
> > 
> > Thanks  
> > Vineeth  
> > On Wed, May 8, 2013 at 5:36 PM, subhankar [neo20...@gmail.com](mailto:neo20...@gmail.com) wrote:
> > 
> > > hi,  
> > > my use case is something like this: i m inserting some data using  
> > > auto id generation. so in future i' don't know what the id it created.  
> > > now if i have  
> > > to insert some field in that doc, i have to search for previous fields and  
> > > update that doc.  
> > > i can do it using two queries search and if not exists then  
> > > update.  
> > > BUT my question is --\> is there any way i can do it in one  
> > > query??????
> > > 
> > > thanks,  
> > > subhankar
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![subhankar\_biswas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subhankar_biswas/32/140090_2.png) [@subhankar\_biswas](https://discuss.elastic.co/u/subhankar_biswas)\
**Post date:** [May 8, 2013, 1:31pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/5 "2013-05-08T13:31:45Z")

</div>

☹

thanks,  
subhankar

On Wednesday, 8 May 2013 18:51:40 UTC+5:30, Vineeth Mohan wrote:

> This plugin is to update all existing documents by query. So if the  
> document does not exist , it wont do anything.  
> I believe what you need is "UPDATE IF EXISTS" , "CREATE IF NOT EXISTS"  
> AFAIK this cant be done in a single query (And hence not atomic)
> 
> Thanks  
> Vineeth
> 
> On Wed, May 8, 2013 at 6:24 PM, subhankar \<[neo20...@gmail.com](mailto:neo20...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > hi vineeth,  
> > i m very new to ES. i saw that earlier.  
> > plz correct me if i am wrong. i think that is for index request. for  
> > update api how this will work. i have to combine the query and update api  
> > both.  
> > and i think  
> > [GitHub - yakaz/elasticsearch-action-updatebyquery: ElasticSearch Update By Query action plugin](https://github.com/yakaz/elasticsearch-action-updatebyquery) will satisfy  
> > the requirement. what do you think. can you please give me a small example  
> > ??
> > 
> > Thanks,  
> > subhankar
> > 
> > On Wednesday, 8 May 2013 18:05:13 UTC+5:30, Vineeth Mohan wrote:
> > 
> > > Just see  
> > > Operation Type in [http://www.elasticsearch.org/](http://www.elasticsearch.org/)\*\*  
> > > guide/reference/api/index\_/[http://www.elasticsearch.org/guide/reference/api/index\_/](http://www.elasticsearch.org/guide/reference/api/index_/)
> > > 
> > > HTH
> > > 
> > > Thanks  
> > > Vineeth  
> > > On Wed, May 8, 2013 at 5:36 PM, subhankar [neo20...@gmail.com](mailto:neo20...@gmail.com) wrote:
> > > 
> > > > hi,  
> > > > my use case is something like this: i m inserting some data using  
> > > > auto id generation. so in future i' don't know what the id it created.  
> > > > now if i have  
> > > > to insert some field in that doc, i have to search for previous fields and  
> > > > update that doc.  
> > > > i can do it using two queries search and if not exists then  
> > > > update.  
> > > > BUT my question is --\> is there any way i can do it in one  
> > > > query??????
> > > > 
> > > > thanks,  
> > > > subhankar
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [May 8, 2013, 2:50pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/6 "2013-05-08T14:50:54Z")

</div>

Hi ,

My apologies , there is one feature that you can use here , i missed it  
earlier. Its caled upsert.  
LINK - [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/update/)

- Generate the docID based on the content of your feed.
- Use upsert to index the document. UPSERT is like update the document  
or create it.

Thanks

```
        Vineeth

```

On Wed, May 8, 2013 at 7:01 PM, subhankar [neo20iitkgp@gmail.com](mailto:neo20iitkgp@gmail.com) wrote:

> ☹
> 
> thanks,  
> subhankar
> 
> On Wednesday, 8 May 2013 18:51:40 UTC+5:30, Vineeth Mohan wrote:
> 
> > This plugin is to update all existing documents by query. So if the  
> > document does not exist , it wont do anything.  
> > I believe what you need is "UPDATE IF EXISTS" , "CREATE IF NOT EXISTS"  
> > AFAIK this cant be done in a single query (And hence not atomic)
> > 
> > Thanks  
> > Vineeth
> > 
> > On Wed, May 8, 2013 at 6:24 PM, subhankar [neo20...@gmail.com](mailto:neo20...@gmail.com) wrote:
> > 
> > > hi vineeth,  
> > > i m very new to ES. i saw that earlier.  
> > > plz correct me if i am wrong. i think that is for index request. for  
> > > update api how this will work. i have to combine the query and update api  
> > > both.  
> > > and i think [https://github.com/\*\*yakaz/elasticsearch-action-](https://github.com/**yakaz/elasticsearch-action-)\*\*  
> > > updatebyquery[https://github.com/yakaz/elasticsearch-action-updatebyquery](https://github.com/yakaz/elasticsearch-action-updatebyquery) will  
> > > satisfy the requirement. what do you think. can you please give me a small  
> > > example ??
> > > 
> > > Thanks,  
> > > subhankar
> > > 
> > > On Wednesday, 8 May 2013 18:05:13 UTC+5:30, Vineeth Mohan wrote:
> > > 
> > > > Just see  
> > > > Operation Type in [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/**g)\*\*  
> > > > uide/reference/api/index\_/[http://www.elasticsearch.org/guide/reference/api/index\_/](http://www.elasticsearch.org/guide/reference/api/index_/)
> > > > 
> > > > HTH
> > > > 
> > > > Thanks  
> > > > Vineeth  
> > > > On Wed, May 8, 2013 at 5:36 PM, subhankar [neo20...@gmail.com](mailto:neo20...@gmail.com) wrote:
> > > > 
> > > > > hi,  
> > > > > my use case is something like this: i m inserting some data using  
> > > > > auto id generation. so in future i' don't know what the id it created.  
> > > > > now if i have  
> > > > > to insert some field in that doc, i have to search for previous fields and  
> > > > > update that doc.  
> > > > > i can do it using two queries search and if not exists then  
> > > > > update.  
> > > > > BUT my question is --\> is there any way i can do it in one  
> > > > > query??????
> > > > > 
> > > > > thanks,  
> > > > > subhankar
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to elasticsearc...@\*\*googlegroups.\*\*com.
> > > > > 
> > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![subhankar\_biswas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subhankar_biswas/32/140090_2.png) [@subhankar\_biswas](https://discuss.elastic.co/u/subhankar_biswas)\
**Post date:** [May 8, 2013, 5:52pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/7 "2013-05-08T17:52:41Z")

</div>

hi vineeth,  
thats may a solution but UPSERT always takes the doc id to  
process. and i m using ES auto generated id so i don't know the id in  
advance . ihave to any way query ES to get the uuid. so may be it is not  
possible. or else i have to use something like snowflake to produce the  
unique id and process it.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [May 8, 2013, 6:10pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/8 "2013-05-08T18:10:22Z")

</div>

Why don't you just create an id for each document that way you don't  
need to deal with this. This can be something as simple as  
concatenating and hashing the field values so instead of doing a  
search for the known fields, just generate that hash and you know the  
exact document id. Now adding a new field will change that hash so  
you will need to delete the old doc and reindex with the new id. Not  
specifying an id is bad practice unless you never need to update/get  
that document again.

On Wed, May 8, 2013 at 10:52 AM, subhankar [neo20iitkgp@gmail.com](mailto:neo20iitkgp@gmail.com) wrote:

> hi vineeth,  
> thats may a solution but UPSERT always takes the doc id to  
> process. and i m using ES auto generated id so i don't know the id in  
> advance . ihave to any way query ES to get the uuid. so may be it is not  
> possible. or else i have to use something like snowflake to produce the  
> unique id and process it.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [May 8, 2013, 6:15pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/9 "2013-05-08T18:15:19Z")

</div>

+1 : definitely the way to go!

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 8 mai 2013 à 20:10, Matt Weber [matt.weber@gmail.com](mailto:matt.weber@gmail.com) a écrit :

> Why don't you just create an id for each document that way you don't  
> need to deal with this. This can be something as simple as  
> concatenating and hashing the field values so instead of doing a  
> search for the known fields, just generate that hash and you know the  
> exact document id. Now adding a new field will change that hash so  
> you will need to delete the old doc and reindex with the new id. Not  
> specifying an id is bad practice unless you never need to update/get  
> that document again.
> 
> On Wed, May 8, 2013 at 10:52 AM, subhankar [neo20iitkgp@gmail.com](mailto:neo20iitkgp@gmail.com) wrote:
> 
> > hi vineeth,  
> > thats may a solution but UPSERT always takes the doc id to  
> > process. and i m using ES auto generated id so i don't know the id in  
> > advance . ihave to any way query ES to get the uuid. so may be it is not  
> > possible. or else i have to use something like snowflake to produce the  
> > unique id and process it.
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![subhankar\_biswas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subhankar_biswas/32/140090_2.png) [@subhankar\_biswas](https://discuss.elastic.co/u/subhankar_biswas)\
**Post date:** [May 8, 2013, 9:57pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/10 "2013-05-08T21:57:30Z")

</div>

hi maat,  
thanks for ur reply. in my use case i'll have to frequently get  
that id back to use else where. then i have produce the ids by myself.

thanks,  
subhankar

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [May 9, 2013, 3:19am UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/11 "2013-05-09T03:19:26Z")

</div>

What is the big overhead in creating the ID yourself. Just find the  
hashcode or sum of content of your feed which is going to be unique for the  
next dupe.

Thanks  
Vineeth

On Thu, May 9, 2013 at 3:27 AM, subhankar [neo20iitkgp@gmail.com](mailto:neo20iitkgp@gmail.com) wrote:

> hi maat,  
> thanks for ur reply. in my use case i'll have to frequently get  
> that id back to use else where. then i have produce the ids by myself.
> 
> thanks,  
> subhankar
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![subhankar\_biswas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subhankar_biswas/32/140090_2.png) [@subhankar\_biswas](https://discuss.elastic.co/u/subhankar_biswas)\
**Post date:** [May 9, 2013, 3:22pm UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/12 "2013-05-09T15:22:29Z")

</div>

thanks for ur reply and advice. i'll create the id by myself.  
basically i badly need a UUID generator. java native UUID generator does  
not guarantee of uniqueness in distributed scenario (as per my superior).  
is the ticketing server explained here(  
[http://blogs.perl.org/users/clinton\_gormley/2011/10/elasticsearchsequence---a-blazing-fast-ticket-server.html](http://blogs.perl.org/users/clinton_gormley/2011/10/elasticsearchsequence---a-blazing-fast-ticket-server.html)  
) is a good idea??

thanks,  
subhankar

On Thursday, 9 May 2013 08:49:26 UTC+5:30, Vineeth Mohan wrote:

> What is the big overhead in creating the ID yourself. Just find the  
> hashcode or sum of content of your feed which is going to be unique for the  
> next dupe.
> 
> Thanks  
> Vineeth
> 
> On Thu, May 9, 2013 at 3:27 AM, subhankar \<[neo20...@gmail.com](mailto:neo20...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > hi maat,  
> > thanks for ur reply. in my use case i'll have to frequently get  
> > that id back to use else where. then i have produce the ids by myself.
> > 
> > thanks,  
> > subhankar
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:37am UTC](https://discuss.elastic.co/t/insert-if-not-exists/11875/13 "2017-07-06T02:37:20Z")

</div>


