Search with point in timeedit

A point in time can be passed to a search request via a PointInTimeBuilder, which requires a point in time ID returned from the open API.

SearchRequest searchRequest = new SearchRequest();
final PointInTimeBuilder pointInTimeBuilder = new PointInTimeBuilder(pitId); 
pointInTimeBuilder.setKeepAlive("2m"); 
searchRequest.source(new SearchSourceBuilder().pointInTimeBuilder(pointInTimeBuilder)); 
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

Create a PointInTimeBuilder with a PIT id

(Optional) Set the keep alive of a point in time

Pass a point in time to a search request

A search request with a point in time does not accept these parameters: indices, indicesOptions routing, preference, and ccsMinimizeRoundtrips.

A point in time can be used in search after requests to paginate search results.