Tutorial: Getting started with Amazon OpenSearch Serverless
This tutorial shows you the basic steps to get an Amazon OpenSearch Serverless search collection up and running quickly. With a search collection, you can 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 Managing Amazon OpenSearch Serverless collections and the other topics within this guide.
You complete the following steps in this tutorial:
-
Note
Use only ASCII characters for your
IndexName. If you do not use ASCII characters for yourIndexName, theIndexNamein CloudWatch metrics is converted to a URL encoded format for non-ASCII characters.
Step 1: Configure permissions
To complete this tutorial and to use OpenSearch Serverless in general, you must have the correct IAM permissions. In this tutorial, you 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:
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
-
Open the Amazon OpenSearch Service console at https://console.aws.amazon.com/aos/home
. -
In the left navigation pane, choose Collections.
-
Choose Create collection.
-
For Name, enter
movies. -
For Collection type, choose Search. For more information, see Choosing a collection type.
-
For Collection creation method, choose Express Create.
-
Review the default settings. These include the collection group, OpenSearch UI application settings, encryption with an AWS owned key, public network access, and the auto-generated data access policy.
-
Choose Create collection.
-
Wait for the collection status to change to
Active. This might take several minutes.
Tip
This tutorial uses the NextGen Express Create method. You can also access Express Create from the Express create button in the info banner on the landing page for a quicker path. For more control over encryption, network, and data access settings, use Standard Create. To use the Classic collection creation wizard, choose Switch to Classic. For more information, see Creating collections.
Step 3: Upload and search data
You can upload data to an OpenSearch Serverless collection using Postman
To index and search data in the movies collection
-
Choose Collections in the left navigation pane and choose the movies collection to open its details page.
-
Choose the OpenSearch Dashboards URL for the collection. The URL takes the format
https://dashboards..{region}.aoss.amazonaws.com/_login/?collectionId={collection-id} -
Within OpenSearch Dashboards, open the left navigation pane and choose Dev Tools.
-
To create a single index called movies-index, send the following request:
PUT movies-index
-
To index a single document into movies-index, send the following request:
PUT movies-index/_doc/1 { "title": "Shawshank Redemption", "genre": "Drama", "year": 1994 } -
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.
-
Choose Next step and then choose Create index pattern. After the pattern is created, you can view the various document fields such as
titleandgenre. -
To begin searching your data, open the left navigation pane again and choose Discover, or use the search API
within Dev Tools.
Handling errors
When you run index and search operations, you might get the following error responses:
-
HTTP 507– Indicates that an internal server error occurred. This error generally indicates that your OpenSearch compute units (OCUs) are overloaded by the volume or complexity of your requests. Although OpenSearch Serverless scales automatically to manage the load, there can be a delay in deploying additional resources.To mitigate this error, implement an exponential backoff retry policy. This approach temporarily reduces the request rate to effectively manage the load. For more details, refer to Retry behavior in the AWS SDKs and Tools Reference Guide.
-
HTTP 402– Indicates that you reached the maximum OpenSearch compute unit (OCU) capacity limit. Optimize your workload to reduce the OCU usage or request a quota increase.
Step 4: Delete the collection
Because the movies collection is for test purposes, delete it when you're done experimenting.
To delete an OpenSearch Serverless collection
-
Go back to the Amazon OpenSearch Service console.
-
Choose Collections in the left navigation pane and select the movies collection.
-
Choose Delete and confirm deletion.
Next steps
Now that you know how to create a collection and index data, you might want to try the following:
-
Explore more advanced options for creating a collection. For more information, see Managing Amazon OpenSearch Serverless collections.
-
Configure security policies to manage collection security at scale. For more information, see Overview of security in Amazon OpenSearch Serverless.
-
Use other methods to index data into collections. For more information, see Ingesting data into Amazon OpenSearch Serverless collections.