From 1171e52cc55bd30d647c68770584eb6f58bd05b4 Mon Sep 17 00:00:00 2001 From: Shoma Okamoto <32533860+shmokmt@users.noreply.github.com> Date: Fri, 29 Dec 2023 02:41:02 +0900 Subject: [PATCH 1/7] Add base64 to gemspec (#218) * Added base64 to gemspec, which will no longer be the default gem in Ruby 3.4 Signed-off-by: shmokmt <32533860+shmokmt@users.noreply.github.com> --- CHANGELOG.md | 1 + opensearch-ruby.gemspec | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a622c4a00..f21165622 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added +- Added base64 gem to gemspec (#218)[https://github.com/opensearch-project/opensearch-ruby/pull/218] ### Changed ### Deprecated ### Removed diff --git a/opensearch-ruby.gemspec b/opensearch-ruby.gemspec index f86f69800..ab1f9a1c1 100644 --- a/opensearch-ruby.gemspec +++ b/opensearch-ruby.gemspec @@ -64,6 +64,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.5' + s.add_dependency 'base64' s.add_dependency 'faraday', '>= 1.0', '< 3' s.add_dependency 'multi_json', '>= 1.0' end From 0ce881686fcc6a6cfd803b54fd8c58224317b648 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Tue, 2 Jan 2024 18:18:48 +0100 Subject: [PATCH 2/7] Remove a todo in the testing workflow (#219) Signed-off-by: Earlopain <14981592+Earlopain@users.noreply.github.com> --- .github/workflows/main.yml | 6 ++---- CHANGELOG.md | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d4db8462a..b247ec2e0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,8 +30,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: ./.github/actions/opensearch with: - # TODO: change cluster-version back to `latest` after OS 2.9.1 or later is released - cluster-version: "2.8.0" + cluster-version: latest disable-security: true - uses: ruby/setup-ruby@v1 with: @@ -65,8 +64,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: ./.github/actions/opensearch with: - # TODO: change cluster-version back to `latest` after OS 2.9.1 or later is released - cluster-version: "2.8.0" + cluster-version: latest disable-security: true - uses: ruby/setup-ruby@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index f21165622..32558f69d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Deprecated ### Removed ### Fixed +- Switch back to the latest OpenSearch version when testing in CI ([#219](https://github.com/opensearch-project/opensearch-ruby/pull/219)) ### Security ## [3.1.0] From fe24161b7f4ea19c8365e726f8ba62f96459916d Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Tue, 2 Jan 2024 21:03:37 +0100 Subject: [PATCH 3/7] Test against ruby 3.3 (#220) Signed-off-by: Earlopain <14981592+Earlopain@users.noreply.github.com> --- .github/workflows/compatibility.yml | 4 ++-- .github/workflows/main.yml | 6 +++--- .github/workflows/test-unreleased.yml | 8 ++++---- CHANGELOG.md | 1 + 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index a8a25b3e7..0bc0fdf99 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -35,7 +35,7 @@ jobs: disable-security: true - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2 + ruby-version: 3.3 - name: Build and test with Rake run: | sudo apt-get update @@ -68,7 +68,7 @@ jobs: disable-security: false - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2 + ruby-version: 3.3 - name: Build and test with Rake run: | sudo apt-get update diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b247ec2e0..f1396d0bc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, jruby-9.3 ] + ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -52,7 +52,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ 2.6, 2.7, '3.0', 3.1, 3.2, jruby-9.3 ] + ruby: [ 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -85,7 +85,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, jruby-9.3 ] + ruby: [ 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3 ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test-unreleased.yml b/.github/workflows/test-unreleased.yml index 349446317..ba684e663 100644 --- a/.github/workflows/test-unreleased.yml +++ b/.github/workflows/test-unreleased.yml @@ -19,10 +19,10 @@ jobs: fail-fast: false matrix: entry: - - { ruby_version: '3.2', opensearch_ref: '1.x' } - - { ruby_version: '3.2', opensearch_ref: '2.x' } - - { ruby_version: '3.2', opensearch_ref: '2.0' } - - { ruby_version: '3.2', opensearch_ref: 'main' } + - { ruby_version: '3.3', opensearch_ref: '1.x' } + - { ruby_version: '3.3', opensearch_ref: '2.x' } + - { ruby_version: '3.3', opensearch_ref: '2.0' } + - { ruby_version: '3.3', opensearch_ref: 'main' } steps: - uses: ruby/setup-ruby@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 32558f69d..4ad4d1362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added - Added base64 gem to gemspec (#218)[https://github.com/opensearch-project/opensearch-ruby/pull/218] +- Added support for Ruby 3.3 ([#220](https://github.com/opensearch-project/opensearch-ruby/pull/220)) ### Changed ### Deprecated ### Removed From 97fac2ab816fc4bf2db1141f4eef5ded08c8bd9e Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Tue, 2 Jan 2024 22:07:13 +0100 Subject: [PATCH 4/7] Remove dependency on the base64 gem (#221) Removed dependency on Base64 gem Signed-off-by: Earlopain <14981592+Earlopain@users.noreply.github.com> --- CHANGELOG.md | 2 +- lib/opensearch/transport/client.rb | 8 ++++---- opensearch-ruby.gemspec | 1 - spec/opensearch/transport/client_spec.rb | 3 ++- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ad4d1362..bc6127cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,11 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added -- Added base64 gem to gemspec (#218)[https://github.com/opensearch-project/opensearch-ruby/pull/218] - Added support for Ruby 3.3 ([#220](https://github.com/opensearch-project/opensearch-ruby/pull/220)) ### Changed ### Deprecated ### Removed +- Removed dependency on the base64 gem ([#221](https://github.com/opensearch-project/opensearch-ruby/pull/221)) ### Fixed - Switch back to the latest OpenSearch version when testing in CI ([#219](https://github.com/opensearch-project/opensearch-ruby/pull/219)) ### Security diff --git a/lib/opensearch/transport/client.rb b/lib/opensearch/transport/client.rb index acbb92814..ee4b60af2 100644 --- a/lib/opensearch/transport/client.rb +++ b/lib/opensearch/transport/client.rb @@ -24,8 +24,6 @@ # specific language governing permissions and limitations # under the License. -require 'base64' - module OpenSearch module Transport # Handles communication with an OpenSearch cluster. @@ -225,7 +223,8 @@ def extract_cloud_creds(arguments) return unless arguments[:cloud_id] && !arguments[:cloud_id].empty? name = arguments[:cloud_id].split(':')[0] - cloud_url, opensearch_instance = Base64.decode64(arguments[:cloud_id].gsub("#{name}:", '')).split('$') + base64_decoded = arguments[:cloud_id].gsub("#{name}:", '').unpack1('m') + cloud_url, opensearch_instance = base64_decoded.split('$') if cloud_url.include?(':') url, port = cloud_url.split(':') @@ -355,7 +354,8 @@ def __auto_detect_adapter # Encode credentials for the Authorization Header # Credentials is the base64 encoding of id and api_key joined by a colon def __encode(api_key) - Base64.strict_encode64([api_key[:id], api_key[:api_key]].join(':')) + joined = [api_key[:id], api_key[:api_key]].join(':') + [joined].pack('m0') end end end diff --git a/opensearch-ruby.gemspec b/opensearch-ruby.gemspec index ab1f9a1c1..f86f69800 100644 --- a/opensearch-ruby.gemspec +++ b/opensearch-ruby.gemspec @@ -64,7 +64,6 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.5' - s.add_dependency 'base64' s.add_dependency 'faraday', '>= 1.0', '< 3' s.add_dependency 'multi_json', '>= 1.0' end diff --git a/spec/opensearch/transport/client_spec.rb b/spec/opensearch/transport/client_spec.rb index 8d556cfb1..050dc458f 100644 --- a/spec/opensearch/transport/client_spec.rb +++ b/spec/opensearch/transport/client_spec.rb @@ -98,7 +98,8 @@ end it 'Adds the ApiKey header to the connection' do - expect(authorization_header).to eq("ApiKey #{Base64.strict_encode64('my_id:my_api_key')}") + strict_base64_encoded = ["my_id:my_api_key"].pack("m0") + expect(authorization_header).to eq("ApiKey #{strict_base64_encoded}") end end From 221eb686fa2077203391ac884b24a002894bb102 Mon Sep 17 00:00:00 2001 From: Theo Nam Truong Date: Wed, 31 Jan 2024 15:21:07 -0700 Subject: [PATCH 5/7] Added search_pipeline (#227) * Added search_pipeline Signed-off-by: Theo Truong * # Signed-off-by: Theo Truong --------- Signed-off-by: Theo Truong --- CHANGELOG.md | 2 ++ lib/opensearch/api/actions/search.rb | 2 ++ lib/opensearch/transport/transport/base.rb | 2 -- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc6127cbe..1495da5d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,12 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added - Added support for Ruby 3.3 ([#220](https://github.com/opensearch-project/opensearch-ruby/pull/220)) +- Added `search_pipeline` parameter to `search` API ([#227](https://github.com/opensearch-project/opensearch-ruby/pull/227)) ### Changed ### Deprecated ### Removed - Removed dependency on the base64 gem ([#221](https://github.com/opensearch-project/opensearch-ruby/pull/221)) +- Removed logging of hosts in `transport` base ([#227](https://github.com/opensearch-project/opensearch-ruby/pull/227)) ### Fixed - Switch back to the latest OpenSearch version when testing in CI ([#219](https://github.com/opensearch-project/opensearch-ruby/pull/219)) ### Security diff --git a/lib/opensearch/api/actions/search.rb b/lib/opensearch/api/actions/search.rb index dec2f1c55..d639cffd1 100644 --- a/lib/opensearch/api/actions/search.rb +++ b/lib/opensearch/api/actions/search.rb @@ -48,6 +48,7 @@ module Actions # @option arguments [String] :q Query in the Lucene query string syntax # @option arguments [List] :routing A comma-separated list of specific routing values # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search + # @option arguments [String] :search_pipeline Customizable sequence of processing stages applied to search queries. # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) # @option arguments [Number] :size Number of hits to return (default: 10) # @option arguments [List] :sort A comma-separated list of : pairs @@ -128,6 +129,7 @@ def search(arguments = {}) q routing scroll + search_pipeline search_type size sort diff --git a/lib/opensearch/transport/transport/base.rb b/lib/opensearch/transport/transport/base.rb index dd0c71e2e..fd96e37e8 100644 --- a/lib/opensearch/transport/transport/base.rb +++ b/lib/opensearch/transport/transport/base.rb @@ -104,9 +104,7 @@ def get_connection(options = {}) # @see Sniffer#hosts # def reload_connections! - puts hosts hosts = sniffer.hosts - puts hosts __rebuild_connections hosts: hosts, options: options self rescue SnifferTimeoutError From 60bc84dfc476c2105441d7111c197da68b96d65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 1 Feb 2024 07:45:51 -1000 Subject: [PATCH 6/7] Add missing quotes (#225) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While here, add syntax highlighting. Signed-off-by: Romain Tartière --- USER_GUIDE.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/USER_GUIDE.md b/USER_GUIDE.md index 1eb22b96a..44036f095 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -13,8 +13,8 @@ To add the client to your project, install it using [RubyGems](https://rubygems. `gem install opensearch-ruby` or add it to your Gemfile: -``` -gem opensearch-ruby +```ruby +gem 'opensearch-ruby' ``` and run: ``` @@ -23,7 +23,9 @@ bundle install Import the client: -`require 'opensearch'` +```ruby +require 'opensearch' +``` ## Basic Usage ```ruby From faf3b79e09dd0b3d28d440b441c8b9ff2d0585c9 Mon Sep 17 00:00:00 2001 From: Theo Nam Truong Date: Mon, 5 Feb 2024 10:21:36 -0700 Subject: [PATCH 7/7] Bumped Version to 3.2.0 (#228) Signed-off-by: Theo Truong --- CHANGELOG.md | 8 ++++++++ lib/opensearch/version.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1495da5d5..d0414d5d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security + +## [3.2.0] +### Added - Added support for Ruby 3.3 ([#220](https://github.com/opensearch-project/opensearch-ruby/pull/220)) - Added `search_pipeline` parameter to `search` API ([#227](https://github.com/opensearch-project/opensearch-ruby/pull/227)) ### Changed diff --git a/lib/opensearch/version.rb b/lib/opensearch/version.rb index 76f2e605d..3d0193638 100644 --- a/lib/opensearch/version.rb +++ b/lib/opensearch/version.rb @@ -25,5 +25,5 @@ # under the License. module OpenSearch - VERSION = '3.1.0'.freeze + VERSION = '3.2.0'.freeze end