> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo OpenSearch

> Hands-on tutorial to provision an Amazon OpenSearch domain, explore OpenSearch Dashboards with sample data, and index documents using the REST API

This tutorial walks through provisioning an Amazon OpenSearch domain (cluster), exploring OpenSearch Dashboards with sample data, and indexing documents using the REST API (curl). It’s designed for a hands-on demo environment — for production deployments, apply stronger availability, security, and sizing choices.

## What you'll do

* Create an OpenSearch domain in the AWS console
* Connect to the cluster and OpenSearch Dashboards
* Add sample data and explore prebuilt dashboards
* Inspect indices and mappings
* Query documents in Discover
* Index documents via the REST API (single PUT and bulk)
* Clean up the domain to avoid charges

***

## 1) Create a domain (cluster)

1. Open the AWS Console, search for **OpenSearch**, and open the service page.
2. Click **Create domain**. A domain is an OpenSearch cluster with its own instance configuration, storage, and settings.
3. Choose **Standard create** to view and control each option (use Easy create only for fast experiments).
4. Select a template: **Production** for production workloads or **Dev/Test** for demos and labs (this guide uses **Dev/Test**).

Key decisions to make during creation (examples shown for a demo):

| Setting                   | Consideration                     | Demo example                                                 |
| ------------------------- | --------------------------------- | ------------------------------------------------------------ |
| Standby nodes             | Automated failover vs cost        | Skip for single-AZ demos; enable for HA                      |
| Availability Zones (AZs)  | Multi-AZ for resilience           | Single AZ for lab                                            |
| OpenSearch engine version | Choose a supported version        | OpenSearch 2.x                                               |
| Instance types & counts   | Size for expected load and shards | `t3.small.search`, 1 node/AZ                                 |
| Storage                   | EBS type and size per node        | 10 GiB EBS for demo                                          |
| Dedicated master nodes    | Improve cluster stability         | Disabled for simple demos                                    |
| Network access            | Public vs VPC                     | VPC + security groups for production; public for short demos |
| Access control            | IAM or master user (fine-grained) | Create master user for this demo                             |

Example ARN format for IAM principals:

```text theme={null}
arn:<partition>:iam::<account>:<type>/<id>
# Example: arn:aws:iam::111122223333:role/my-administrator
```

Specify a master username and a strong password (for example `admin` + a strong password). If fine-grained access control is enabled, OpenSearch Dashboards will require these credentials on login.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/N4R4aUhm-yJiOGwk/images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/aws-opensearch-domain-creation-finegrained-admin.jpg?fit=max&auto=format&n=N4R4aUhm-yJiOGwk&q=85&s=485694dcd833a66f98b07e3dde535072" alt="A screenshot of the AWS OpenSearch domain creation page showing fine-grained access control enabled with a created master user (username &#x22;admin&#x22;) and a masked password, alongside a Summary panel listing engine version, data node, network and encryption settings." width="1920" height="1080" data-path="images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/aws-opensearch-domain-creation-finegrained-admin.jpg" />
</Frame>

<Callout icon="warning" color="#FF6B6B">
  Using public access makes your cluster reachable from the internet. For production use a VPC and restrictive security groups. Only use public access for short-lived demos.
</Callout>

Other optional settings: SAML or Amazon Cognito authentication, index-level access policies, encryption at rest and in transit, automatic software updates, and advanced cluster parameters. After reviewing settings, create the domain — provisioning typically takes 15–20 minutes.

***

## 2) Connect to the cluster

* When the domain status becomes **Active**, open domain details to find the **Cluster endpoint** and the **OpenSearch Dashboards URL**.
* Use the cluster endpoint for API calls and the Dashboards URL for the UI.
* Log in to OpenSearch Dashboards with the master username/password. On first login you’ll be prompted about tenants — the default Global tenant is fine for demos.

<Callout icon="lightbulb" color="#1CB2FE">
  Keep your domain endpoint and master credentials private. Consider storing credentials in a secrets manager for repeatable scripts.
</Callout>

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/N4R4aUhm-yJiOGwk/images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-demo-domain-console.jpg?fit=max&auto=format&n=N4R4aUhm-yJiOGwk&q=85&s=efcba500f6af1ddadb4011cef2b654b9" alt="A screenshot of the Amazon OpenSearch Service console displaying the &#x22;demo&#x22; domain details — showing domain status (Active), cluster health (Green), OpenSearch version, and domain endpoint links. The left sidebar shows navigation for Managed clusters, Serverless, and other OpenSearch settings." width="1920" height="1080" data-path="images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-demo-domain-console.jpg" />
</Frame>

***

## 3) Add sample data in OpenSearch Dashboards

1. Open OpenSearch Dashboards and choose **Add data**.
2. Select a sample dataset (e.g., Sample eCommerce orders, Sample flight data, or Sample web logs).
3. Click **Add data** to install the dataset and then **View Data** to open its dashboard and indices.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/N4R4aUhm-yJiOGwk/images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-dashboards-sample-data-cards.jpg?fit=max&auto=format&n=N4R4aUhm-yJiOGwk&q=85&s=d85ad0714c3e920dbf1b98b165a89779" alt="A screenshot of the OpenSearch Dashboards &#x22;Add sample data&#x22; page showing three sample dataset cards: Sample eCommerce orders, Sample flight data, and Sample web logs, each with preview visualizations and &#x22;Add data&#x22; buttons. The page header and navigation bar are visible at the top." width="1920" height="1080" data-path="images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-dashboards-sample-data-cards.jpg" />
</Frame>

After installing the eCommerce dataset, open its dashboard to review metrics and visualizations.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/N4R4aUhm-yJiOGwk/images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-ecommerce-revenue-dashboard.jpg?fit=max&auto=format&n=N4R4aUhm-yJiOGwk&q=85&s=d809d7b4c4caa0a8ff76c2ec3c65d7dd" alt="A screenshot of an OpenSearch eCommerce Revenue Dashboard showing key metrics and visualizations. It displays transactions per day (139), average order value (75.25), average items per order (2.163), total revenue (77,583.36) and charts for sales by gender and category." width="1920" height="1080" data-path="images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-ecommerce-revenue-dashboard.jpg" />
</Frame>

***

## 4) Inspect indices and mappings

* In OpenSearch Dashboards go to **Management → Index Management → Indices** to see indices created by the sample dataset.
* Select an index and open the **Mappings** tab to view defined fields and types. Reviewing mappings helps you plan queries, aggregations, and future index settings.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/N4R4aUhm-yJiOGwk/images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-dashboards-ecommerce-mappings.jpg?fit=max&auto=format&n=N4R4aUhm-yJiOGwk&q=85&s=2a4c8e49d7fe241af2c80fc3a539316e" alt="A screenshot of the OpenSearch Dashboards index detail view showing the &#x22;Mappings&#x22; tab for a sample ecommerce index. It lists field mappings in the Visual Editor (e.g., category, currency, customer_first_name, customer_id, geoip.continent_name)." width="1920" height="1080" data-path="images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-dashboards-ecommerce-mappings.jpg" />
</Frame>

***

## 5) Explore documents with Discover

* Open **Discover** in Dashboards, choose the correct index pattern for your dataset, and browse documents.
* Adjust the time range (e.g., last 7 days) and use the left-hand field list to filter or add fields to the display.
* Example: add filters for `manufacturer` = `Pyramid Distribution` and `days_of_week` = `Saturday` to show documents matching both conditions.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/N4R4aUhm-yJiOGwk/images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-dashboards-discover-ecommerce-logs.jpg?fit=max&auto=format&n=N4R4aUhm-yJiOGwk&q=85&s=a368582622a9e343d7f7cfc8dea3e60b" alt="A screenshot of an OpenSearch Dashboards &#x22;Discover&#x22; view showing a histogram and filtered e-commerce log results: a left panel of available fields and a right pane listing JSON-like order records with highlighted terms." width="1920" height="1080" data-path="images/Introduction-to-AWS-Databases/AWS-Databases-Part-2/Demo-OpenSearch/opensearch-dashboards-discover-ecommerce-logs.jpg" />
</Frame>

***

## 6) Indexing documents via the REST API (curl)

AWS documentation includes curl examples for indexing. Replace `admin`, `Password123!`, and the domain endpoint with your master username, password, and the domain endpoint URL.

Reference:

* [Amazon OpenSearch Service Developer Guide](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/)

### Index a single document (PUT)

Example PUT request to index one document into an index named `movies`:

```bash theme={null}
curl -XPUT -u 'admin:Password123!' 'https://search-demo-xxxxxxxxxxxx.us-east-1.es.amazonaws.com/movies/_doc/1' \
  -H 'Content-Type: application/json' \
  -d '{"director":"Burton, Tim","genre":["Comedy","Sci-Fi"],"year":1996,"actor":["Jack Nicholson","Pierce Brosnan","Sarah Jessica Parker"],"title":"Mars Attacks!"}'
```

Expected response (trimmed):

```json theme={null}
{"_index":"movies","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}
```

### Bulk indexing (multiple documents)

1. Create a local file `bulk_movies.json` containing newline-delimited JSON (action/metadata line followed by the document source line for each item). Example `bulk_movies.json`:

```json theme={null}
{ "index" : { "_index": "movies", "_id" : "2" } }
{"director":"Frankenheimer, John","genre":["Drama","Mystery","Thriller","Crime"],"year":1962,"actor":["Lansbury, Angela","Sinatra, Frank"]}
{ "index" : { "_index": "movies", "_id" : "3" } }
{"director":"Baird, Stuart","genre":["Action","Crime","Thriller"],"year":1998,"actor":["Downey Jr., Robert","Jones, Tommy Lee"]}
{ "index" : { "_index": "movies", "_id" : "4" } }
{"director":"Ray, Nicholas","genre":["Drama","Romance"],"year":1955,"actor":["Hopper, Dennis","Wood, Natalie","Dean, James"],"title":"Rebel Without a Cause"}
```

Note: The bulk file must use newline-separated JSON lines and should end with a newline.

2. Call the bulk API:

```bash theme={null}
curl -XPOST -u 'admin:Password123!' 'https://search-demo-xxxxxxxxxxxx.us-east-1.es.amazonaws.com/_bulk' \
  --data-binary @bulk_movies.json \
  -H 'Content-Type: application/json'
```

Expected response (trimmed):

```json theme={null}
{"took":61,"errors":false,"items":[{"index":{"_index":"movies","_id":"2","result":"created"}},{"index":{"_index":"movies","_id":"3","result":"created"}},{"index":{"_index":"movies","_id":"4","result":"created"}}]}
```

***

## 7) Verify documents in Dashboards

* In OpenSearch Dashboards go to **Management → Index Patterns** and create an index pattern named `movies`.
* Open **Discover**, select the `movies` pattern, and search for terms (for example, `Downey Jr., Robert`) to validate newly indexed documents.

***

## 8) Clean up

To avoid ongoing charges, delete the OpenSearch domain when you finish:

* Open the OpenSearch console → Domains → select your domain → **Delete**.

***

## Links and references

* Amazon OpenSearch Service Developer Guide: [https://docs.aws.amazon.com/opensearch-service/latest/developerguide/](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/)
* OpenSearch project: [https://opensearch.org/](https://opensearch.org/)
* More on indexing and the Bulk API: [https://opensearch.org/docs/latest/opensearch/rest-api/bulk/](https://opensearch.org/docs/latest/opensearch/rest-api/bulk/)

This completes the lesson on provisioning an Amazon OpenSearch domain, using OpenSearch Dashboards with sample data, and indexing documents via the REST API.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/introduction-to-aws-databases/module/6b775562-0b27-41e9-93fc-bb16dab05d87/lesson/167596e5-3d9c-4e78-8802-b343bff462ea" />
</CardGroup>
