From e8104c930b6a481217e53d08545dca64ee1ec38a Mon Sep 17 00:00:00 2001 From: dblock Date: Mon, 26 Dec 2022 19:17:40 -0500 Subject: [PATCH] Changes required to communicate with OpenSearch serverless. Signed-off-by: dblock --- Gemfile | 2 +- Gemfile.lock | 29 +++++++++++++++++------------ example.rb | 10 +++++----- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 06679b9..fc8226b 100644 --- a/Gemfile +++ b/Gemfile @@ -9,4 +9,4 @@ source 'https://rubygems.org' -gem 'opensearch-aws-sigv4', '~> 1.0.0' +gem 'opensearch-aws-sigv4', github: 'opensearch-project/opensearch-ruby' diff --git a/Gemfile.lock b/Gemfile.lock index 2416bdc..9068333 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,17 +1,10 @@ -GEM - remote: https://rubygems.org/ +GIT + remote: https://github.com/opensearch-project/opensearch-ruby.git + revision: 76f5308e74aa22e1cd9fbd0954c84eb6171e116d specs: - aws-eventstream (1.2.0) - aws-sigv4 (1.5.2) - aws-eventstream (~> 1, >= 1.0.2) - faraday (2.7.2) - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) - faraday-net_http (3.0.2) - multi_json (1.15.0) opensearch-api (2.1.0) multi_json - opensearch-aws-sigv4 (1.0.0) + opensearch-aws-sigv4 (1.1.0) aws-sigv4 (~> 1) opensearch-ruby (>= 1.0.1) opensearch-ruby (2.1.0) @@ -20,13 +13,25 @@ GEM opensearch-transport (2.1.0) faraday (>= 1.0, < 3) multi_json + +GEM + remote: https://rubygems.org/ + specs: + aws-eventstream (1.2.0) + aws-sigv4 (1.5.2) + aws-eventstream (~> 1, >= 1.0.2) + faraday (2.7.4) + faraday-net_http (>= 2.0, < 3.1) + ruby2_keywords (>= 0.0.4) + faraday-net_http (3.0.2) + multi_json (1.15.0) ruby2_keywords (0.0.5) PLATFORMS arm64-darwin-21 DEPENDENCIES - opensearch-aws-sigv4 (~> 1.0.0) + opensearch-aws-sigv4! BUNDLED WITH 2.3.24 diff --git a/example.rb b/example.rb index 3410741..e682c9a 100644 --- a/example.rb +++ b/example.rb @@ -13,7 +13,7 @@ require 'aws-sigv4' signer = Aws::Sigv4::Signer.new( - service: 'es', + service: 'aoss', region: ENV['AWS_REGION'] || 'us-east-1', access_key_id: ENV['AWS_ACCESS_KEY_ID'] || raise('Missing AWS_ACCESS_KEY_ID.'), secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'] || raise('Missing AWS_SECRET_ACCESS_KEY.'), @@ -22,11 +22,11 @@ client = OpenSearch::Aws::Sigv4Client.new({ host: ENV['OPENSEARCH_ENDPOINT'] || raise('Missing OPENSEARCH_ENDPOINT.'), - log: false + log: true }, signer) -info = client.info -puts info['version']['distribution'] + ': ' + info['version']['number'] +# info = client.info +# puts info['version']['distribution'] + ': ' + info['version']['number'] # create an index index = 'movies' @@ -35,7 +35,7 @@ begin # index data document = { title: 'Moneyball', director: 'Bennett Miller', year: 2011 } - client.index(index: index, body: document, id: '1', refresh: true) + client.index(index: index, body: document, id: '1') # wait for the document to index sleep(3)