Skip to content

dblock/opensearch-rust-client-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenSearch Ruby Client Demo

Makes requests to Amazon OpenSearch Service using the OpenSearch Rust Client. Supports OpenSearch Serverless since version 2.1.0.

Prerequisites

Rust

Install Rust. YMMV.

$ rustc --version
rustc 1.65.0

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-west-2

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

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

opensearch: 2.3.0

{
  "_shards": {
    "failed": 0,
    "skipped": 0,
    "successful": 5,
    "total": 5
  },
  "hits": {
    "hits": [
      {
        "_id": "8qhYDoYBpJvbGlZLDVk_",
        "_index": "movies",
        "_score": 0.2876821,
        "_source": {
          "director": "Bennett Miller",
          "title": "Moneyball",
          "year": 2011
        }
      }
    ],
    "max_score": 0.2876821,
    "total": {
      "relation": "eq",
      "value": 1
    }
  },
  "timed_out": false,
  "took": 4
}

The code creates an index, adds a document, then cleans up.

License

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

Copyright

Copyright OpenSearch Contributors. See NOTICE for details.

About

OpenSearch Rust Client Demo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages