# Best way to check a document has been indexed

**URL:** <https://discuss.elastic.co/t/best-way-to-check-a-document-has-been-indexed/20863>\
**Category:** Elasticsearch\
**Created:** [November 20, 2014, 10:31am UTC](https://discuss.elastic.co/t/best-way-to-check-a-document-has-been-indexed/20863 "2014-11-20T10:31:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asanchez](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@asanchez](https://discuss.elastic.co/u/asanchez)\
**Post date:** [November 20, 2014, 10:31am UTC](https://discuss.elastic.co/t/best-way-to-check-a-document-has-been-indexed/20863/1 "2014-11-20T10:31:08Z")

</div>

Hello,

I'm developing a piece of code that inserts a document into an  
elastcisearch server. The code uses libcurl to setup an HTTP request and  
capture the response.  
So, in order to check wether a document has been properly indexed, what is  
the official or proper way to do it?

This is an example of a correct indexed document response:

HTTP/1.1 201 Created  
Content-Type: application/json; charset=UTF-8  
Content-Length: 92

{"\_index":"someindex","\_type":"sometype","\_id":"fsAx6qXcQGCSrY1DWvQACw","\_version":1,"created":true}

Should my program check that first header line contains "201 Created", what  
should happen if a 3xx redirection occurs? should I consider it as properly  
indexed too?

Or instead should I just ignore the header and just check that the last  
part of the body string equals ' "created":true} ' ?

Thank you!

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3b1ea5c6-61bf-4ce4-976a-705e17f3927f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3b1ea5c6-61bf-4ce4-976a-705e17f3927f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [November 20, 2014, 12:58pm UTC](https://discuss.elastic.co/t/best-way-to-check-a-document-has-been-indexed/20863/2 "2014-11-20T12:58:50Z")

</div>

Hi ,

Just check if its 200 ( Indexed ) or 201 ( Created ) .  
HTTP status code alone should be sufficient.

Thanks  
Vineeth

On Thu, Nov 20, 2014 at 4:01 PM, asanchez [asanchez1987@gmail.com](mailto:asanchez1987@gmail.com) wrote:

> Hello,
> 
> I'm developing a piece of code that inserts a document into an  
> elastcisearch server. The code uses libcurl to setup an HTTP request and  
> capture the response.  
> So, in order to check wether a document has been properly indexed, what is  
> the official or proper way to do it?
> 
> This is an example of a correct indexed document response:
> 
> HTTP/1.1 201 Created  
> Content-Type: application/json; charset=UTF-8  
> Content-Length: 92
> 
> {"\_index":"someindex","\_type":"sometype","\_id":"fsAx6qXcQGCSrY1DWvQACw","\_version":1,"created":true}
> 
> Should my program check that first header line contains "201 Created",  
> what should happen if a 3xx redirection occurs? should I consider it as  
> properly indexed too?
> 
> Or instead should I just ignore the header and just check that the last  
> part of the body string equals ' "created":true} ' ?
> 
> Thank you!
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/3b1ea5c6-61bf-4ce4-976a-705e17f3927f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3b1ea5c6-61bf-4ce4-976a-705e17f3927f%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/3b1ea5c6-61bf-4ce4-976a-705e17f3927f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3b1ea5c6-61bf-4ce4-976a-705e17f3927f%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nMsA%3DkFzSGwApWK-5f8mUmK8YdJuvKn\_Zct7yn550Aeg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nMsA%3DkFzSGwApWK-5f8mUmK8YdJuvKn_Zct7yn550Aeg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:48am UTC](https://discuss.elastic.co/t/best-way-to-check-a-document-has-been-indexed/20863/3 "2017-07-06T00:48:42Z")

</div>


