Skip to content

dblock/opensearch-node-client-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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://github.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.

About

OpenSearch Node.js Client Demo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published