# What does Setrefresh do while index a document?

**URL:** <https://discuss.elastic.co/t/what-does-setrefresh-do-while-index-a-document/12277>\
**Category:** Elasticsearch\
**Created:** [June 5, 2013, 12:34pm UTC](https://discuss.elastic.co/t/what-does-setrefresh-do-while-index-a-document/12277 "2013-06-05T12:34:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arjit\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Arjit\_Gupta](https://discuss.elastic.co/u/Arjit_Gupta)\
**Post date:** [June 5, 2013, 12:34pm UTC](https://discuss.elastic.co/t/what-does-setrefresh-do-while-index-a-document/12277/1 "2013-06-05T12:34:59Z")

</div>

Hi,

I am new to elastic search. I just want to know what does setrefresh do ?  
from the docs  
[http://www.elasticsearch.org/guide/reference/api/index\_/](http://www.elasticsearch.org/guide/reference/api/index_/)  
It says it makes it available to search.  
I am interested in knowing some internals to how does refresh happen ?  
Does it refreshes the whole cache ? Or only merges the segments which  
contains the document.  
Does setrefersh effects "other" documents also ?

--  
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:** ![Arjit\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Arjit\_Gupta](https://discuss.elastic.co/u/Arjit_Gupta)\
**Post date:** [June 6, 2013, 1:20am UTC](https://discuss.elastic.co/t/what-does-setrefresh-do-while-index-a-document/12277/2 "2013-06-06T01:20:08Z")

</div>

Any one ?

On Wednesday, June 5, 2013 6:04:59 PM UTC+5:30, Arjit Gupta wrote:

> Hi,
> 
> I am new to Elasticsearch. I just want to know what does setrefresh do ?  
> from the docs  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/index_/)  
> It says it makes it available to search.  
> I am interested in knowing some internals to how does refresh happen ?  
> Does it refreshes the whole cache ? Or only merges the segments which  
> contains the document.  
> Does setrefersh effects "other" documents also ?

--  
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:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 6, 2013, 8:25am UTC](https://discuss.elastic.co/t/what-does-setrefresh-do-while-index-a-document/12277/3 "2013-06-06T08:25:22Z")

</div>

Hey

refreshing is an expensive operation, which makes data, that has been  
recently indexed, available for searching.  
Because it is that expensive, a refresh is executed once per second in the  
background instead of every indexing operation.

Refresh does not refresh a cache. Refresh does not do a merge.  
Refresh affects all documents, which have been indexed since the last  
refresh.

So what does it do? In order to understand this, you need to know, that a  
lucene index reader (which is used for searches at the end) is always a  
snapshot of data at a certain time. In order to search in recently indexed  
documents, you need move the point in time and index reader can read from,  
to a newer point. And this is exactly what the refresh call is doing.

Hope this helps a bit.

--Alex

On Thu, Jun 6, 2013 at 3:20 AM, Arjit Gupta [arjit292@gmail.com](mailto:arjit292@gmail.com) wrote:

> Any one ?
> 
> On Wednesday, June 5, 2013 6:04:59 PM UTC+5:30, Arjit Gupta wrote:
> 
> > Hi,
> > 
> > I am new to Elasticsearch. I just want to know what does setrefresh do ?  
> > from the docs  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/**guide/reference/api/index_/)[http://www.elasticsearch.org/guide/reference/api/index\_/](http://www.elasticsearch.org/guide/reference/api/index_/)  
> > It says it makes it available to search.  
> > I am interested in knowing some internals to how does refresh happen ?  
> > Does it refreshes the whole cache ? Or only merges the segments which  
> > contains the document.  
> > Does setrefersh effects "other" documents also ?
> > 
> > --  
> > 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:** ![a1senfter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a1senfter/32/3998_2.png) [@a1senfter](https://discuss.elastic.co/u/a1senfter)\
**Post date:** [August 3, 2015, 3:26pm UTC](https://discuss.elastic.co/t/what-does-setrefresh-do-while-index-a-document/12277/4 "2015-08-03T15:26:24Z")

</div>

Hi to all,  
thanks Alexander for your explanation. But I've an additional question when using the bulk index/update call via node-client with enabled refresh option in elasticsearch version 1.5.2.  
Is it guaranteed that the IndexReader is updated during the _bulkRequest.execute().actionGet()_ method call, so that all new or updated docs are searchable directly afterwards?

---

<div class="post-metadata">

**Author:** ![a1senfter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a1senfter/32/3998_2.png) [@a1senfter](https://discuss.elastic.co/u/a1senfter)\
**Post date:** [August 25, 2015, 7:52am UTC](https://discuss.elastic.co/t/what-does-setrefresh-do-while-index-a-document/12277/5 "2015-08-25T07:52:50Z")

</div>

Has anyone a hint for me?

---

<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 5, 2017, 11:54pm UTC](https://discuss.elastic.co/t/what-does-setrefresh-do-while-index-a-document/12277/6 "2017-07-05T23:54:02Z")

</div>


