Getting started with Amazon OpenSearch Serverless - Amazon OpenSearch Service

Getting started with Amazon OpenSearch Serverless

This tutorial walks you through the basic steps to get an Amazon OpenSearch Serverless search collection up and running quickly. A search collection allows you to power applications in your internal networks and internet-facing applications, such as ecommerce website search and content search.

To learn how to use a vector search collection, see Working with vector search collections. For more detailed information about using collections, see Creating, listing, and deleting Amazon OpenSearch Serverless collections and the other topics within this guide.

You'll complete the following steps in this tutorial:

Step 1: Configure permissions

In order to complete this tutorial, and to use OpenSearch Serverless in general, you must have the correct IAM permissions. In this tutorial, you will create a collection, upload and search data, and then delete the collection.

Your user or role must have an attached identity-based policy with the following minimum permissions:

{ "Version": "2012-10-17", "Statement": [ { "Action": [ "aoss:CreateCollection", "aoss:ListCollections", "aoss:BatchGetCollection", "aoss:DeleteCollection", "aoss:CreateAccessPolicy", "aoss:ListAccessPolicies", "aoss:UpdateAccessPolicy", "aoss:CreateSecurityPolicy", "aoss:GetSecurityPolicy", "aoss:UpdateSecurityPolicy", "iam:ListUsers", "iam:ListRoles" ], "Effect": "Allow", "Resource": "*" } ] }

For more information about OpenSearch Serverless IAM permissions, see Identity and Access Management for Amazon OpenSearch Serverless.

Step 2: Create a collection

A collection is a group of OpenSearch indexes that work together to support a specific workload or use case.

To create an OpenSearch Serverless collection
  1. Open the Amazon OpenSearch Service console at https://console.aws.amazon.com/aos/home.

  2. Choose Collections in the left navigation pane and choose Create collection.

  3. Name the collection movies.

  4. For collection type, choose Search. For more information, see Choosing a collection type.

  5. For Security, choose Standard create.

  6. Under Encryption, select Use AWS owned key. This is the AWS KMS key that OpenSearch Serverless will use to encrypt your data.

  7. Under Network, configure network settings for the collection.

    • For the access type, select Public.

    • For the resource type, choose both Enable access to OpenSearch endpoints and Enable access to OpenSearch Dashboards. Since you'll upload and search data using OpenSearch Dashboards, you need to enable both.

  8. Choose Next.

  9. For Configure data access, set up access settings for the collection. Data access policies allow users and roles to access the data within a collection. In this tutorial, we'll provide a single user the permissions required to index and search data in the movies collection.

    Create a single rule that provides access to the movies collection. Name the rule Movies collection access.

  10. Choose Add principals, IAM users and roles and select the user or role that you'll use to sign in to OpenSearch Dashboards and index data. Choose Save.

  11. Under Index permissions, select all of the permissions.

  12. Choose Next.

  13. For the access policy settings, choose Create a new data access policy and name the policy movies.

  14. Choose Next.

  15. Review your collection settings and choose Submit. Wait several minutes for the collection status to become Active.

Step 3: Upload and search data

You can upload data to an OpenSearch Serverless collection using Postman or cURL. For brevity, these examples use Dev Tools within the OpenSearch Dashboards console.

To index and search data in the movies collection
  1. Choose Collections in the left navigation pane and choose the movies collection to open its details page.

  2. Choose the OpenSearch Dashboards URL for the collection. The URL takes the format https://dashboards.{region}.aoss.amazonaws.com/_login/?collectionId={collection-id}.

  3. Within OpenSearch Dashboards, open the left navigation pane and choose Dev Tools.

  4. To create a single index called movies-index, send the following request:

    PUT movies-index
  5. To index a single document into movies-index, send the following request:

    PUT movies-index/_doc/1 { "title": "Shawshank Redemption", "genre": "Drama", "year": 1994 }
  6. To search data in OpenSearch Dashboards, you need to configure at least one index pattern. OpenSearch uses these patterns to identify which indexes you want to analyze. Open the left navigation pane, choose Stack Management, choose Index Patterns, and then choose Create index pattern. For this tutorial, enter movies.

  7. Choose Next step and then choose Create index pattern. After the pattern is created, you can view the various document fields such as title and genre.

  8. To begin searching your data, open the left navigation pane again and choose Discover, or use the search API within Dev Tools.

Step 4: Delete the collection

Because the movies collection is for test purposes, make sure to delete it when you're done experimenting.

To delete an OpenSearch Serverless collection
  1. Go back to the Amazon OpenSearch Service console.

  2. Choose Collections in the left navigation pane and select the movies collection.

  3. Choose Delete and confirm deletion.

Next steps

Now that you know how to create a collection and index data, you might want to try some of the following exercises: