Home > database >  refreshInterval = "-1" not working in spring-data-elasticsearch
refreshInterval = "-1" not working in spring-data-elasticsearch

Time:09-28

I'm using extended ElasticsearchRepository to access elasticsearch records. This is the Document I'm using with repository.

@Data
@Builder
@Document(indexName = "index", shards = 1, replicas = 0, refreshInterval = "-1")
@NoArgsConstructor
@AllArgsConstructor
public class ESDocument {
...

However I see that POST traffic with refresh request is sent to server, but since POST is forbidden for my user I get HTTP error 403. Is refreshInterval = "-1" option enough to disable refresh calls toward elastic search server?

CodePudding user response:

The refreshIntervall in the @Document annotation defines the corresponding parameter in the index settings when an index is created by the Spring Data Elasticsearch repository.

If you get a 403 because you are not allowed to send POST request has nothing to do with the refresh intervall. That a POST request is sent for a query is not something that Spring Data Elasticsearch is responsible for, that's the behaviour of the Elasticsearch RestHighLevelClient that is used.

If you cannot POST to prevent changes in Elasticsearch, your cluster should be configured properly for access roles (https://www.elastic.co/guide/en/elasticsearch/reference/current/authorization.html).

  • Related