opensearch-go-client-demo

command module
v0.0.0-...-bad06d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

README

OpenSearch Go Client Demo

Makes requests to Amazon OpenSearch using the OpenSearch Go Client. Works for both managed OpenSearch and OpenSearch Serverless since version 2.2.0.

Prerequisites

Go

Install Go. YMMV.

$ go version
go version go1.19.4 darwin/arm64

Running

Create an OpenSearch domain in (AWS) which support IAM based AuthN/AuthZ.

export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_SESSION_TOKEN=
export AWS_REGION=us-west2

export SERVICE=es # use aoss for OpenSearch Serverless
export ENDPOINT=https://....us-west-2.es.amazonaws.com

$ go run main.go

This will output the version of OpenSearch and a search result.

opensearch: 2.3.0
[map[_id:1 _index:movies _score:0.18232156 _source:map[director:Bennett Miller title:Moneyball year:2011]]]

The code will create an index, add a document to it, search, then cleanup.

License

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

Copyright OpenSearch Contributors. See NOTICE for details.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL