Point in Time (PIT) lets you run different queries against a dataset that is fixed in time.
To create a PIT, first create an index.
java
String index = "sample-index";
CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(index).build();
client.indices().create(createIndexRequest);
To create a PIT, the keep_alive query parameter is required; it specifies how long to keep a PIT.
CreatePitRequest createPitRequest = new CreatePitRequest.Builder()
.targetIndexes(Collections.singletonList(index))
.keepAlive(new Time.Builder().time("100m").build()).build();
CreatePitResponse createPitResponse = client.createPit(createPitRequest);
Returns all PITs in the OpenSearch cluster.
ListAllPitResponse listAllPitResponse = client.listAllPit();
Deletes one, several, or all PITs. PITs are automatically deleted when the keep_alive time period elapses. However, to deallocate resources, you can delete a PIT using the Delete PIT API. The Delete PIT API supports deleting a list of PITs by ID or deleting all PITs at once.
DeletePitRequest deletePitRequest = new DeletePitRequest.Builder()
.pitId(Collections.singletonList(createPitResponse.pitId())).build();
DeletePitResponse deletePitResponse = client.deletePit(deletePitRequest);
You can find a working sample of the above code in PointInTime.java.