# Force synchronous refresh

**URL:** https://discuss.elastic.co/t/force-synchronous-refresh/383535
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [November 19, 2025, 1:43pm UTC](https://discuss.elastic.co/t/force-synchronous-refresh/383535 "2025-11-19T13:43:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Elastic04](https://avatars.discourse-cdn.com/v4/letter/e/e9c0ed/32.png) [@Elastic04](https://discuss.elastic.co/u/Elastic04)
#### Post date: [November 19, 2025, 1:43pm UTC](https://discuss.elastic.co/t/force-synchronous-refresh/383535/1 "2025-11-19T13:43:52Z")

</div>

We have this part of code in indexing job.

1. turn off refresh\_interval before indexing. (set refresh\_interval to 0 or -1 through kibana)

2. After indexing is done, we to do manual refresh so that indexed products will be available for searching.

```auto
​private void forceSynchronousRefresh(String indexId)
    {
        try (RuntimeSensor sensor = getPerformanceMgr().start(PerformanceMgr.SENSOR_TYPE_CLASS,
                        this.getClass().getSimpleName() + ".forceSynchronousRefresh()"))
        {
            if (null !=indexId || !indexId.trim().isEmpty())
            {
                RefreshResponse refreshResponse = server.getClient().indices().refresh(new RefreshRequest(indexId),
                                RequestOptions.DEFAULT);

            // Logger.info(this, "Index refresh success for {}: totalShards={}, successfulShards={}, failedShards={}",
                   // indexId, refreshResponse.getTotalShards(), refreshResponse.getSuccessfulShards(),
                // refreshResponse.getFailedShards());

                System.out.println("Index refresh success for " + indexId +
                                ": totalShards=" + refreshResponse.getTotalShards() +
                                ", successfulShards=" + refreshResponse.getSuccessfulShards() +
                                ", failedShards=" + refreshResponse.getFailedShards());
            }
        }
        catch(Exception e)
        {
            Logger.error(this, MessageFormat.format("Index refresh failure for {0}", indexId), e);
        }
    }

```

---

<div class="post-metadata">

### Author: ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)
#### Post date: [November 27, 2025, 11:52am UTC](https://discuss.elastic.co/t/force-synchronous-refresh/383535/2 "2025-11-27T11:52:10Z")

</div>

Hello!

Setting `refresh_interval` to -1 does effectively disable automatic refreshes, meaning newly added documents won’t be searchable. If you were following the [Tune for indexing speed guide](https://www.elastic.co/docs/deploy-manage/production-guidance/optimize-performance/indexing-speed), it recommends enabling automatic refreshing again after the indexing has been completed.

Another option is to manual refresh, which is what your code is doing with the call to the Refresh API, which works, but note that “Refresh requests are synchronous and do not return a response until the refresh operation completes” (from the [refresh docs](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-refresh)), so it might affect the application’s performance.
