Java REST Client - Refresh API and Default Refresh Index

enerijunior
Tue, 03 Jun 2025 15:48:40 +0000
Elasticsearch

Hello, everyone!

I have a question about using the Java REST Client - Refresh API or the default refresh behavior in an Elasticsearch index.

In a certain part of an application I'm maintaining, I have an implementation that calls refresh after each indexing operation using:

RefreshResponse refreshResponse = client. Indices().refresh(request, RequestOptions.DEFAULT);

Doc: (Refresh API | Java REST Client [7.17] | Elastic)

I need to make an adjustment here for performance reasons.

When reading the Elasticsearch documentation, I came across the following parameter:

refresh_interval

Doc: (Refresh an index | Elasticsearch API documentation).

As I understand it, if this parameter is not explicitly set, Elasticsearch will perform a refresh operation every second on indexes that have received any requests in the last 30 seconds.

My question is: Do the two approaches serve the same purpose? In other words, is one an explicit API call on demand and the other the default automatic mechanism? If they are equivalent, I could reconsider my indexing approach and rely on the default update behavior instead of manually calling the API each time.

Thanks in advance for any insight!

2 posts - 2 participants