Skip to content

Latest commit

 

History

History
69 lines (43 loc) · 1.58 KB

README.md

File metadata and controls

69 lines (43 loc) · 1.58 KB

OpenSearch Node.js Client Demo

Makes requests to Amazon OpenSearch using the OpenSearch Node.js Client. Written in TypeScript. Supports OpenSearch Serverless since opensearch-js 2.2.0.

Install Prerequisites

Nvm

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.

Node.js

Install the latest LTS node.js. Use nvm ls-remote to find the latest version.

nvm install v18.12.1

Install Packages

Install dependencies.

npm install

Running

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

License

This project is licensed under the Apache v2.0 License.

Copyright

Copyright OpenSearch Contributors. See NOTICE for details.