在 AWS OpenSearch Service 2.5 版本中,删除的文档可以通过 opensearch-py 库恢复。opensearch-py 是一个用于与 AWS OpenSearch Service 进行交互的 Python 客户端库。

下面是使用 opensearch-py 恢复已删除文档的步骤:

  1. 首先,确保已经安装了 opensearch-py 库。可以使用 pip 命令进行安装:
pip install opensearch-py
  1. 导入 opensearch-py 库:
from opensearchpy import OpenSearch
  1. 创建一个 OpenSearch 对象,用于与 AWS OpenSearch Service 进行交互。需要提供 AWS OpenSearch Service 的终端节点和访问凭证信息:
opensearch = OpenSearch(
    ['https://<your-opensearch-endpoint>'],
    http_auth=('username', 'password'),
    use_ssl=True,
    verify_certs=True,
    ca_certs='/path/to/ca-bundle.pem'
)
  1. 使用 recovery API 来恢复已删除的文档。需要提供要恢复的索引名称和文档 ID:
opensearch.recovery(
    index='<your-index-name>',
    body={
        "actions": [
            {"restore": {"index": "<your-index-name>", "doc_id": "<your-doc-id>"}}
        ]
    }
)

替换 <your-opensearch-endpoint>、<your-index-name> 和 <your-doc-id> 为实际的值。

恢复请求将会返回一个 JSON 响应,其中包含恢复操作的结果信息。

请注意,恢复操作可能需要一些时间来完成。您可以使用 opensearch-py 提供的其他 API 来检查恢复操作的状态,例如使用 cat/recovery API 来获取恢复操作的进度信息。

希望这些步骤可以帮助您恢复已删除的文档

aws opensearch服务25版本标记为deleted documents如何通过opensearch-py恢复

原文地址: https://www.cveoy.top/t/topic/ilI2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录