entzik entzik - 28 days ago 6
Java Question

Is there a way to specify write consistency level when using spring data's ElasticSearchTemplate?

when using the elastic search java client it is possible to specify the write consistency level and timeout for each query:




final IndexRequestBuilder indexRequestBuilder = client.prepareIndex("myIndex", "myType");
indexRequestBuilder.setConsistencyLevel(WriteConsistencyLevel.ALL);
indexRequestBuilder.setTimeout(TimeValue.timeValueMillis(500));

final XContentBuilder sourceBuilder = .....

indexRequestBuilder.setSource(sourceBuilder).execute().actionGet();





I did not find an API to do the same with Spring Data's ElasticSearchTemplate.

Do you know if there is a way?

Answer

after checking with the spring folks at devoxx.be it looks like there isn't a way to specify write consistency and timeout per query with SpringData's ElasticSearchTemplate.