# Question about default refresh\_interval and upsert

**URL:** <https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581>\
**Category:** Elasticsearch\
**Created:** [December 3, 2020, 8:02pm UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581 "2020-12-03T20:02:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbrt](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@dbrt](https://discuss.elastic.co/u/dbrt)\
**Post date:** [December 3, 2020, 8:02pm UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581/1 "2020-12-03T20:02:56Z")

</div>

Hello everyone,

First of all, I am pretty new to ElasticSearch; please forgive me if the answer to my questions are obvious.

We have switched to ElasticSearch 7.x from ElasticSearch 6.8 and I was very interested by the new behavior of refresh\_interval: " If this setting is not explicitly set, shards that haven’t seen search traffic for at least index.search.idle.after seconds will not receive background refreshes until they receive a search request".

In our case, we do bulk upsert at a pretty high rate but not, in general, when indexes are searched. I think I understand pretty well the behavior but I was wondering if the fact that we are using upsert (we force the id of the document and want to make sure we update any existing document with same id) instead of always creating a new document makes a different, does searching a document with same id is considered as a search request on the index?

I have a side question, I have not been able to find how to log all the refresh requests done by ElasticSearch (for debugging purpose); is this possible?

Thanks for your time

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 4, 2020, 1:40am UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581/2 "2020-12-04T01:40:57Z")

</div>

Welcome to our community! 😃

> [@dbrt](#):
>
> First of all, I am pretty new to Elasticsearch

No worries. Do note that it's Elasticsearch, not a camel case S 🙂

> [@dbrt](#):
>
> does searching a document with same id is considered as a search request on the index

Yep, it's a search unless you are doing a `GET` on the `_id`.

> [@dbrt](#):
>
> I have a side question, I have not been able to find how to log all the refresh requests done by Elasticsearch (for debugging purpose); is this possible?

As in API requests to `_refresh`?

---

<div class="post-metadata">

**Author:** ![dbrt](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@dbrt](https://discuss.elastic.co/u/dbrt)\
**Post date:** [December 4, 2020, 7:53am UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581/3 "2020-12-04T07:53:27Z")

</div>

Thanks for your answer

> [@warkolm](#):
>
> > [@dbrt](#):
> >
> > does searching a document with same id is considered as a search request on the index
> 
> Yep, it's a search unless you are doing a `GET` on the `_id`.

Sorry, I was not clear. I don't do a search but I do an update of the document by specifying the document \_id. This, I guess, causes a search of the document internally using the `_id`; it is this search I was referring to. Anyway, I suppose you have answered my question since this search is likely based on the `_id`.

> [@warkolm](#):
>
> > [@dbrt](#):
> >
> > I have a side question, I have not been able to find how to log all the refresh requests done by Elasticsearch (for debugging purpose); is this possible?
> 
> As in API requests to `_refresh`?

I was more thinking about logging the refresh actions triggered internally by Elasticsearch (with the good naming this time 🙂) after a document is inserted/updated. I know this will cause a large amount of logging but it was to make sure I clearly understand the underlying processing.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 4, 2020, 7:57am UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581/4 "2020-12-04T07:57:26Z")

</div>

If you are doing upserts I believe refreshes would be triggered, at least when updating a document that has not already been refreshed.

---

<div class="post-metadata">

**Author:** ![dbrt](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@dbrt](https://discuss.elastic.co/u/dbrt)\
**Post date:** [December 4, 2020, 8:04am UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581/5 "2020-12-04T08:04:53Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> If you are doing upserts I believe refreshes would be triggered, at least when updating a document that has not already been refreshed.

Yes, I am sure the refresh will be triggered but I am wondering when. Does the upsert command causes the index to exit the "search idle" state (if it was already in this state of course) or will the refresh be triggered only after the search idle timeout (or when a search request is done through another call).

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [December 4, 2020, 9:06am UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581/6 "2020-12-04T09:06:14Z")

</div>

A refresh would trigger any time you are upserting a document that exists in the transaction log and have not yet been refreshed. This is why frequent updates of single documents is very expensive in Elasticsearch as it triggers frequent small expensive refreshes. I am not sure if it would trigger refreshes on other conditions, but this means that the frequency of refreshes will depend on your update patterns.

---

<div class="post-metadata">

**Author:** ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)\
**Post date:** [December 4, 2020, 12:17pm UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581/7 "2020-12-04T12:17:40Z")

</div>

It has been changed back and forth, hence can be confusing, but in the latest ES versions updates do NOT trigger refreshes. A more detailed history can be read in this [github PR](https://github.com/elastic/elasticsearch/pull/48843).

About logging refreshes, I am wondering if looking at refresh count in [index stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html) could be helpful.

---

<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:** [January 1, 2021, 12:18pm UTC](https://discuss.elastic.co/t/question-about-default-refresh-interval-and-upsert/257581/8 "2021-01-01T12:18:07Z")

</div>

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