# Modifying Refresh Settings for BulkIngester Instances

**URL:** <https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699>\
**Category:** Elasticsearch\
**Created:** [February 20, 2024, 1:39pm UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699 "2024-02-20T13:39:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivelin\_Yanev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivelin_yanev/32/130754_2.png) [@Ivelin\_Yanev](https://discuss.elastic.co/u/Ivelin_Yanev)\
**Post date:** [February 20, 2024, 1:39pm UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/1 "2024-02-20T13:39:37Z")

</div>

Hi team,

I'm currently working with the `BulkIngester` in my Elasticsearch project and I have a question regarding the refresh setting.

After creating the `BulkIngester` instance using the following code snippet:

```auto
ingester = BulkIngester.of(
    b -> b.client(esClient)
          .maxOperations(elasticSearchConfig.maxOperations())
          .flushInterval(elasticSearchConfig.flushInterval(), TimeUnit.SECONDS)
          .globalSettings(builder -> builder.refresh(Refresh.True))
          .listener(new BulkIngesterListener()));

```

I've been trying to figure out how to change the refresh setting from `Refresh.True` to `Refresh.False`, but so far, I haven't found a proper way to do it.

Could you please advise if there's a way to modify the refresh setting after the `BulkIngester` has been created?

Alternatively, if modifying the refresh setting directly is not possible, I'm curious if it's feasible to have multiple `BulkIngester` instances with different refresh settings concurrently.

Any insights or suggestions would be greatly appreciated. Thank you!

---

<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:** [February 20, 2024, 4:18pm UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/2 "2024-02-20T16:18:10Z")

</div>

I'm curious about the "why" here.  
Normally, what I do on my side is to refresh the index outside the bulkIngester, ie when I need to call search.

Why would you want to it on and off?

---

<div class="post-metadata">

**Author:** ![Ivelin\_Yanev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivelin_yanev/32/130754_2.png) [@Ivelin\_Yanev](https://discuss.elastic.co/u/Ivelin_Yanev)\
**Post date:** [February 21, 2024, 6:11am UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/3 "2024-02-21T06:11:59Z")

</div>

Hi @dadoonet ,

Thank you for your question. The current approach I'm taking involves using the new Java library (v8.2). Initially, this approach seemed unfamiliar to me as well. However, after conducting some research on the matter, I've found that the recommended approach is to utilize **refresh on search** by setting `refresh=true` in your GET API calls.

However, it's important to note that this method doesn't guarantee the absolutely latest data in every scenario, correct? If this is the case, I'm curious about how to ensure that the data found in the index is indeed the latest available.

Looking forward to your insights on this matter

---

<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:** [February 21, 2024, 3:05pm UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/4 "2024-02-21T15:05:27Z")

</div>

It does guarantee that the latest data that have been indexed is now visible.

---

<div class="post-metadata">

**Author:** ![Ivelin\_Yanev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivelin_yanev/32/130754_2.png) [@Ivelin\_Yanev](https://discuss.elastic.co/u/Ivelin_Yanev)\
**Post date:** [February 21, 2024, 8:15pm UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/5 "2024-02-21T20:15:17Z")

</div>

@dadoonet Ah, I couldn't locate any information regarding the efficacy of utilizing **refresh on search** by setting `refresh=true` in my GET API calls to ensure that the latest indexed data is immediately visible. Can you share with me if your know where is this documentation?

---

<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:** [February 21, 2024, 11:15pm UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/6 "2024-02-21T23:15:51Z")

</div>

Have a look at [Tune for indexing speed | Elasticsearch Guide [8.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html#_unset_or_increase_the_refresh_interval)

---

<div class="post-metadata">

**Author:** ![Ivelin\_Yanev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivelin_yanev/32/130754_2.png) [@Ivelin\_Yanev](https://discuss.elastic.co/u/Ivelin_Yanev)\
**Post date:** [February 22, 2024, 6:07am UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/7 "2024-02-22T06:07:07Z")

</div>

@dadoonet Thank you very much. However, my understanding is that having `refresh=true` in every GET API call triggers a refresh of indices with each call. Wouldn't this potentially impact performance negatively?

---

<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:** [February 22, 2024, 6:17am UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/8 "2024-02-22T06:17:51Z")

</div>

Refreshing frequently, either ahead of a query or through every bulk request, adds a lot of overhead and can have a huge negative performance on indexing throughput. Performing a refresh is an expensive operation which is why Elasticsearch by default does not do it for every operation but rather at a configurable interval. If you look at the guidelines for [tuning indexing throughput](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/tune-for-indexing-speed.html) you can see that one of the main recommendations is to disable or lengthen the refresh interval. Instead making it more frequent than the default value naturally has the opposite effect.

---

<div class="post-metadata">

**Author:** ![Ivelin\_Yanev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivelin_yanev/32/130754_2.png) [@Ivelin\_Yanev](https://discuss.elastic.co/u/Ivelin_Yanev)\
**Post date:** [February 22, 2024, 8:59am UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/9 "2024-02-22T08:59:47Z")

</div>

@Christian_Dahlqvist So, if we use `refresh=true` in every GET API call, wouldn't that seriously impact performance?

@dadoonet if my understanding is correct, wouldn't it be more appropriate to refresh the index inside the bulkIngester rather than externally?

I'm feeling a bit confused about this.

---

<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:** [February 22, 2024, 9:22am UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/10 "2024-02-22T09:22:06Z")

</div>

> [@Ivelin\_Yanev](#):
>
> So, if we use `refresh=true` in every GET API call, wouldn't that seriously impact performance?

How often do you query the data? How are you querying the data? If you are querying frequently you will end up refreshing the index frequently, so it is not necessarily much better that refreshing after each bulk request and will affect indexing performance. If you only query occasionally it is likely a lot better to refresh ahead of the query rather than for each bulk request, although it may still affect indexing performance.

Frequent refreshes, irrespective of how they are triggered, has a negative impact on indexing performance.

---

<div class="post-metadata">

**Author:** ![Ivelin\_Yanev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivelin_yanev/32/130754_2.png) [@Ivelin\_Yanev](https://discuss.elastic.co/u/Ivelin_Yanev)\
**Post date:** [February 22, 2024, 9:49am UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/11 "2024-02-22T09:49:49Z")

</div>

@Christian_Dahlqvist The data is queried frequently, which is why I decided to refresh the index during the bulk step. Creating, updating, or deleting documents in the index is not a common occurrence.

---

<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:** [March 21, 2024, 9:50am UTC](https://discuss.elastic.co/t/modifying-refresh-settings-for-bulkingester-instances/353699/12 "2024-03-21T09:50:24Z")

</div>

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