From d1f2eab41e8f0e8f3dcf10054dd4a7987a5543ff Mon Sep 17 00:00:00 2001 From: DJ Carrillo <60985926+Djcarrillo6@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:38:56 -0800 Subject: [PATCH] Fix/issue 638/updated point in time guide (#661) * Updated point in time guide & CHANGELOG. Signed-off-by: Djcarrillo6 * Updated point in time guide. Signed-off-by: Djcarrillo6 CHAGELOG w/PR info. Signed-off-by: Djcarrillo6 --------- Signed-off-by: Djcarrillo6 --- CHANGELOG.md | 1 + guides/point_in_time.md | 45 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbcdd0c5..8f88e1bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Incorporated API generation into CI workflow and fixed 'generate' nox session ([#660](https://github.com/opensearch-project/opensearch-py/pull/660)) ### Changed - Updated the `get_policy` API in the index_management plugin to allow the policy_id argument as optional ([#633](https://github.com/opensearch-project/opensearch-py/pull/633)) +- Updated the `point_in_time.md` guide with examples demonstrating the usage of the new APIs as alternatives to the deprecated ones. ([#661](https://github.com/opensearch-project/opensearch-py/pull/661)) ### Deprecated ### Removed - Removed unnecessary `# -*- coding: utf-8 -*-` headers from .py files ([#615](https://github.com/opensearch-project/opensearch-py/pull/615), [#617](https://github.com/opensearch-project/opensearch-py/pull/617)) diff --git a/guides/point_in_time.md b/guides/point_in_time.md index 49c84c24..0c9cdb84 100644 --- a/guides/point_in_time.md +++ b/guides/point_in_time.md @@ -1,6 +1,7 @@ -- [Point-in-Time](#point-in-time) +- [Point-in-Time - Deprecated Implementation Examples](#point-in-time---deprecated-implementation-examples) +- [Point-in-Time - Updated Implementation Examples](#point-in-time---updated-implementation-examples) -### Point-in-Time +### Point-in-Time - Deprecated Implementation Examples [Point in Time (PIT)](https://opensearch.org/docs/latest/search-plugins/point-in-time/) lets you run different queries against a dataset that is fixed in time. @@ -41,3 +42,43 @@ Delete all point in time. response = client.delete_point_in_time(body=None, all=True) print(response) ``` + + +### Point-in-Time - Updated Implementation Examples + +Create a point in time on an index. + +```python +index_name = "test-index" +response = client.create_pit( + index=index_name, + params={"keep_alive": "1m"} +) + +pit_id = response.get("pit_id") +print('\n Point in time ID:') +print(pit_id) +``` + + +List all point in time which are alive in the cluster. + +```python +response = client.get_all_pits() +print(response) +``` + +Delete a point in time. + +```python +pit_body = {"pit_id": pit_id} +response = client.delete_pit(body=pit_body) +print(response) +``` + +Delete all point in time. + +```python +response = client.delete_all_pits() +print(response) +```