# Get & delete document

**URL:** https://discuss.elastic.co/t/get-delete-document/5760
**Category:** Elasticsearch
**Created:** [November 3, 2011, 9:13am UTC](https://discuss.elastic.co/t/get-delete-document/5760 "2011-11-03T09:13:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Tomasz\_Kloc](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@Tomasz\_Kloc](https://discuss.elastic.co/u/Tomasz_Kloc)
#### Post date: [November 3, 2011, 9:13am UTC](https://discuss.elastic.co/t/get-delete-document/5760/1 "2011-11-03T09:13:00Z")

</div>

Hello,

To use get or delete method i need to know document's ID. What solution  
is better:

- store ID of indexed document in my main database with object which  
was indexed (needs extra write operation on database)
- filter for certain document to get its ID and then delete (needs  
extra query to ES)

P.S. In online docs ID is an integer, but in ES I see random string. Is  
documentation outdated?

tk

---

<div class="post-metadata">

### Author: ![avasilenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avasilenko/32/2901_2.png) [@avasilenko](https://discuss.elastic.co/u/avasilenko)
#### Post date: [November 3, 2011, 9:17am UTC](https://discuss.elastic.co/t/get-delete-document/5760/2 "2011-11-03T09:17:57Z")

</div>

Hello Tomasz,

You can combine filtering and deleting document, by using delete by query -

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Regards,  
Alexandr Vasilenko

2011/11/3 Tomasz Kloc [tomek.kloc.iit@gmail.com](mailto:tomek.kloc.iit@gmail.com)

> Hello,
> 
> To use get or delete method i need to know document's ID. What solution is  
> better:
> 
> - store ID of indexed document in my main database with object which was  
> indexed (needs extra write operation on database)
> - filter for certain document to get its ID and then delete (needs extra  
> query to ES)
> 
> P.S. In online docs ID is an integer, but in ES I see random string. Is  
> documentation outdated?
> 
> tk

---

<div class="post-metadata">

### Author: ![Tomasz\_Kloc](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@Tomasz\_Kloc](https://discuss.elastic.co/u/Tomasz_Kloc)
#### Post date: [November 3, 2011, 9:21am UTC](https://discuss.elastic.co/t/get-delete-document/5760/3 "2011-11-03T09:21:54Z")

</div>

Thanks!

One more question. Is there a possibility to update indexed document? Or  
should I delete and then reindex?

On 03.11.2011 10:17, Alex Vasilenko wrote:

> Hello Tomasz,
> 
> You can combine filtering and deleting document, by using delete by  
> query -  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/delete-by-query.html)
> 
> Regards,  
> Alexandr Vasilenko
> 
> 2011/11/3 Tomasz Kloc \<[tomek.kloc.iit@gmail.com](mailto:tomek.kloc.iit@gmail.com)  
> [mailto:tomek.kloc.iit@gmail.com](mailto:tomek.kloc.iit@gmail.com)\>
> 
> ```
> Hello,
> 
> To use get or delete method i need to know document's ID. What
> solution is better:
> * store ID of indexed document in my main database with object
> which was indexed (needs extra write operation on database)
> * filter for certain document to get its ID and then delete
> (needs extra query to ES)
> 
> P.S. In online docs ID is an integer, but in ES I see random
> string. Is documentation outdated?
> 
> tk
> 
> ```

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [November 3, 2011, 9:23am UTC](https://discuss.elastic.co/t/get-delete-document/5760/4 "2011-11-03T09:23:35Z")

</div>

Hi Tomasz

> To use get or delete method i need to know document's ID. What solution  
> is better:
> 
> - store ID of indexed document in my main database with object which  
> was indexed (needs extra write operation on database)
> - filter for certain document to get its ID and then delete (needs  
> extra query to ES)

Presumably your docs already have an ID in your database, so why not  
just use that ID when indexing your docs in ES?

> P.S. In online docs ID is an integer, but in ES I see random string. Is  
> documentation outdated?

An ID in ES is a string, but that string can contain just numbers.

clint

---

<div class="post-metadata">

### Author: ![Tomasz\_Kloc](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@Tomasz\_Kloc](https://discuss.elastic.co/u/Tomasz_Kloc)
#### Post date: [November 3, 2011, 9:41am UTC](https://discuss.elastic.co/t/get-delete-document/5760/5 "2011-11-03T09:41:16Z")

</div>

On 03.11.2011 10:23, Clinton Gormley wrote:

> Hi Tomasz
> 
> > To use get or delete method i need to know document's ID. What solution  
> > is better:
> > 
> > - store ID of indexed document in my main database with object which  
> > was indexed (needs extra write operation on database)
> > - filter for certain document to get its ID and then delete (needs  
> > extra query to ES)
> 
> Presumably your docs already have an ID in your database, so why not  
> just use that ID when indexing your docs in ES?

I wasn't aware of that feature, thanks.

---

<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, 3:49am UTC](https://discuss.elastic.co/t/get-delete-document/5760/6 "2017-07-06T03:49:57Z")

</div>


