Connect to OpenSearch with Python

In this example, we will use Python OpenSearch client library.

Prerequisites

You need to install Python on your machine. Depending on your operating system, download and install python. Note: This sample code uses Python3.

  1.  Installation

Install Python opensearch-py client package using pip

To connect to clusters using HTTPS with the Python client, you will also need to install certifi:

  2. Connect to Cluster
  3. Indexing
  4. Getting a document
  5. Deleting a document and an index

Full sample code

Replace public IP, username and password with your real setting