Skip to content

aws-samples/sample-for-amazon-opensearch-service-tutorials-101

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

OpenSearch Tutorial Application

This project demonstrates various OpenSearch search capabilities through a web application built with Cloudscape React and AWS services.

Overview

The application provides examples of different search functionalities using Amazon OpenSearch Service, including:

  • Keyword Search
    • Prefix Match
    • Multi Match
    • Fuzzy Search
    • Minimum Should Match
    • Wildcard Match
    • Range Filter
    • Compound Queries
    • Aggregations
  • Semantic Search (Disk vs In-Memory modes)
  • Hybrid Search (Disk vs In-Memory modes)
  • Document Indexing

Architecture

Architecture

The application is built using:

  • Frontend: React with Cloudscape Design System
  • Backend: AWS Lambda functions / API Gateway
  • Search: Amazon OpenSearch Service
  • Infrastructure: AWS CDK
  • Hosting: AWS App Runner
  • Authentication: Amazon Cognito

Prerequisites

  • Node.js 16 or later
  • Python 3.10 or later
  • AWS CDK v2.91.0
  • AWS CLI configured with appropriate credentials

Deployment Steps

  1. Search for Cloudshell service on the AWS Console and follow the steps below to clone the github repository Cloudshell-service

  2. Clone the sample-for-amazon-opensearch-tutorials-101 repository using the below command:

git clone https://github.com/aws-samples/sample-for-amazon-opensearch-tutorials-101.git
  1. Head on to the sample-for-amazon-opensearch-tutorials-101 folder using the below command
cd sample-for-amazon-opensearch-tutorials-101
cloudshell-deployment
  1. Deploy the infrastructure:
sh installer.sh

Note: triggering builder.sh directly runs the script in Cloudshell which could terminate due to inactivity. We recommend running installer.sh which triggers a codebuild job.

  1. Press Enter to confirm deployment

  2. The deployment takes 30 minutes to create all resources. You can track its progress on Cloudformation Screenshot 2025-04-01 at 4 55 24 pm

  3. Once done, head to AppRunner to obtain the application url Screenshot 2025-04-01 at 4 56 45 pm

  4. Get started by first creating your account on the Opensearch tutorial Application Screenshot 2025-04-01 at 5 01 51 pm

  5. To test out Keyword search functionality, first index some products on the Opensearch tutorial application. Every feature is also accompanied by a guide, best practices and links to the Opensearch documentation. You could also index a custom product. Opensearch-UI-tutorial

  6. Updated features lexical-semantic-search

Note: The builder script will:

  • Deploy the Lambda Layer Stack
  • Build and deploy the OpenSearch Proxy Stack
  • Build and deploy the UI container
  • Deploy the App Runner hosting stack

Environment Configuration

The application supports three environments:

  • dev
  • qa
  • sandbox

Configuration for each environment is managed in cdk.json.

Cleanup

Delete all the deployed resources

cdk destroy

Project Structure

.
├── app.py                      # CDK app entry point
├── artifacts/
│   ├── index_lambda/          # Document indexing function
│   ├── opensearch-app-ui/     # React frontend application
│   └── search_lambda/         # Search functionality
├── builder.sh                 # Deployment automation script
├── search_tutorials/          # CDK infrastructure stacks
└── requirements.txt           # Python dependencies

Security

The application implements several security measures:

  • Private VPC for OpenSearch domain
  • AWS IAM roles and policies for service access
  • HTTPS enforcement for all API endpoints
  • Cognito user authentication

Development

Frontend Development

The UI is located in artifacts/opensearch-app-ui/ and can be run locally:

cd artifacts/opensearch-app-ui
npm install
npm run dev

Infrastructure Development

Infrastructure is defined using AWS CDK in the search_tutorials/ directory: