Makes requests to Amazon OpenSearch using the OpenSearch Node.js Client. Written in TypeScript. Supports OpenSearch Serverless since opensearch-js 2.2.0.
Use nvm to install node.js.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
Follow the intructions to add nvm.sh
and other environment setup to .bashrc
, reopen a new shell.
Install the latest LTS node.js. Use nvm ls-remote
to find the latest version.
nvm install v18.12.1
Install dependencies.
npm install
Create an OpenSearch domain in (AWS) which support IAM based AuthN/AuthZ and run the demo.
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_SESSION_TOKEN=
export AWS_REGION=us-west-2
export SERVICE=es # use aoss for OpenSearch Serverless
export ENDPOINT=https://....us-west-2.es.amazonaws.com
ts-node src/index.ts
The code will connect to OpenSearch, display its version, create an index, add a document, search for it, output the search result, then cleanup.
opensearch: 2.3.0
{ title: 'Moneyball', director: 'Bennett Miller', year: 2011 }
Run with DEBUG=*
to see detailed output.
DEBUG=* ts-node src/index.ts
This project is licensed under the Apache v2.0 License.
Copyright OpenSearch Contributors. See NOTICE for details.