Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 1.9 KB

point_in_time.md

File metadata and controls

53 lines (36 loc) · 1.9 KB

Point-in-Time

Point in Time (PIT) lets you run different queries against a dataset that is fixed in time.

Point-In-Time API

Creating a point 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);                

List all point in time

Returns all PITs in the OpenSearch cluster.

ListAllPitResponse listAllPitResponse = client.listAllPit();

Delete point in time

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.