Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking changes for 2.0 #65

Merged
merged 6 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/test-unreleased.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Integration with Unreleased OpenSearch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be add the workflow in a different PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it in the same PR since the breaking changes need to be tested. WDYT? I can add the workflow in a separate PR and include only 1.x branch on it, then in this PR I can add the 2.x, 2.0 and main branch testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha its ok.
Its easier to split pieces when they are independent, we can do it next time :)


on:
push:
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry:
- { opensearch_ref: '1.x' }
- { opensearch_ref: '2.x' }
- { opensearch_ref: '2.0' }
- { opensearch_ref: 'main' }
steps:
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1

- name: Checkout OpenSearch
uses: actions/checkout@v2
with:
repository: opensearch-project/OpenSearch
ref: ${{ matrix.entry.opensearch_ref }}
path: opensearch

- name: Assemble OpenSearch
run: |
cd opensearch
./gradlew assemble

# This step runs the docker image generated during gradle assemble in OpenSearch. It is tagged as opensearch:test.
# Reference: https://github.com/opensearch-project/OpenSearch/blob/2.0/distribution/docker/build.gradle#L190
- name: Run Docker Image
run: |
docker run -p 9200:9200 -p 9600:9600 -d -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" opensearch:test
sleep 90

- name: Checkout Ruby Client
uses: actions/checkout@v2

- name: Build and test with Rake
run: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev
ruby -v
rake bundle:clean
rake bundle:install

- name: opensearch-ruby
run: cd opensearch && bundle exec rake test:all
- name: opensearch-transport
run: cd opensearch-transport && bundle exec rake test:all
- name: opensearch-api
run: cd opensearch-api && bundle exec rake test:spec
- name: opensearch-dsl
run: cd opensearch-dsl && bundle exec rake test:all
7 changes: 6 additions & 1 deletion COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ The below matrix shows the compatibility of the [`opensearch-ruby`](https://ruby
| 1.2.3 | 1.0.0 |
| 1.2.4 | 1.0.0 |
| 1.3.0 | 1.0.0 |
| 1.3.1 | 1.0.0 |
| 1.3.1 | 1.0.0 |
| 2.0.0 | 2.0.0 |

## Upgrading

Major versions of OpenSearch introduce breaking changes that require careful upgrades of the client. While `opensearch-ruby-client` 2.0.0 works against OpenSearch 1.3.1, certain deprecated features removed in OpenSearch 2.0 have also been removed from the client. Please refer to the [OpenSearch documentation](https://opensearch.org/docs/latest/clients/index/) for more information.
4 changes: 2 additions & 2 deletions opensearch-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require 'opensearch'

client = OpenSearch::Client.new(log: true)

client.index(index: 'myindex', type: 'mytype', id: 1, body: { title: 'Test' })
client.index(index: 'myindex', id: 1, body: { title: 'Test' })
# => {"_index"=>"myindex", ... "created"=>true}

client.search(index: 'myindex', body: { query: { match: { title: 'test' } } })
Expand Down Expand Up @@ -106,7 +106,7 @@ p client.cluster.health
# --> GET _cluster/health {}
# => "{"cluster_name":"opensearch" ... }"

p client.index index: 'myindex', type: 'mytype', id: 'custom', body: { title: "Indexing from my client" }
p client.index index: 'myindex', id: 'custom', body: { title: "Indexing from my client" }
# --> PUT myindex/mytype/custom {} {:title=>"Indexing from my client"}
# => "{"ok":true, ... }"
```
Expand Down
2 changes: 1 addition & 1 deletion opensearch-api/lib/opensearch/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module API

COMMON_PARAMS = [
:ignore, # Client specific parameters
:index, :type, :id, # :index/:type/:id
:index, :id, # :index/:id
:body, # Request body
:node_id, # Cluster
:name, # Alias, template, settings, warmer, ...
Expand Down
1 change: 0 additions & 1 deletion opensearch-api/lib/opensearch/api/actions/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ module Actions
#
# @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
# to perform the operation on all indices
# @option arguments [String] :type The name of the document type
# @option arguments [Hash] :body The search definition using the Query DSL
# @option arguments [Boolean] :verbose Specify whether to return verbose statistics about each iteration
# (default: false)
Expand Down
8 changes: 1 addition & 7 deletions opensearch-api/lib/opensearch/api/actions/bulk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module Actions
# Allows to perform multiple index/update/delete operations in a single request.
#
# @option arguments [String] :index Default index for items which don't provide one
# @option arguments [String] :type Default document type for items which don't provide one
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
# @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for)
# @option arguments [String] :routing Specific routing value
Expand All @@ -54,12 +53,8 @@ def bulk(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = OpenSearch::API::HTTP_POST
path = if _index && _type
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_bulk"
elsif _index
path = if _index
"#{Utils.__listify(_index)}/_bulk"
else
"_bulk"
Expand All @@ -85,7 +80,6 @@ def bulk(arguments = {})
:refresh,
:routing,
:timeout,
:type,
:_source,
:_source_excludes,
:_source_includes,
Expand Down
7 changes: 1 addition & 6 deletions opensearch-api/lib/opensearch/api/actions/count.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module Actions
# Returns number of documents matching a query.
#
# @option arguments [List] :index A comma-separated list of indices to restrict the results
# @option arguments [List] :type A comma-separated list of types to restrict the results
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
# @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled
# @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
Expand Down Expand Up @@ -61,12 +60,8 @@ def count(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = OpenSearch::API::HTTP_POST
path = if _index && _type
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_count"
elsif _index
path = if _index
"#{Utils.__listify(_index)}/_count"
else
"_count"
Expand Down
1 change: 0 additions & 1 deletion opensearch-api/lib/opensearch/api/actions/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module Actions
#
# @option arguments [String] :id Document ID
# @option arguments [String] :index The name of the index
# @option arguments [String] :type The type of the document *Deprecated*
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
# @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for)
# @option arguments [String] :routing Specific routing value
Expand Down
9 changes: 1 addition & 8 deletions opensearch-api/lib/opensearch/api/actions/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module Actions
#
# @option arguments [String] :id The document ID
# @option arguments [String] :index The name of the index
# @option arguments [String] :type The type of the document *Deprecated*
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
# @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for)
# @option arguments [String] :routing Specific routing value
Expand Down Expand Up @@ -60,14 +59,8 @@ def delete(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = OpenSearch::API::HTTP_DELETE
path = if _index && _type && _id
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
else
"#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
end
path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

body = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module Actions
# Deletes documents matching the provided query.
#
# @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*)
# @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types
# @option arguments [String] :analyzer The analyzer to use for the query string
# @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
# @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR)
Expand Down Expand Up @@ -83,14 +82,8 @@ def delete_by_query(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = OpenSearch::API::HTTP_POST
path = if _index && _type
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_delete_by_query"
else
"#{Utils.__listify(_index)}/_delete_by_query"
end
path = "#{Utils.__listify(_index)}/_delete_by_query"
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

body = arguments[:body]
Expand Down
9 changes: 1 addition & 8 deletions opensearch-api/lib/opensearch/api/actions/exists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module Actions
#
# @option arguments [String] :id The document ID
# @option arguments [String] :index The name of the index
# @option arguments [String] :type The type of the document (use `_all` to fetch the first document matching the ID across all types) *Deprecated*
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
# @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
Expand Down Expand Up @@ -62,14 +61,8 @@ def exists(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = OpenSearch::API::HTTP_HEAD
path = if _index && _type && _id
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
else
"#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
end
path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

body = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module Actions
#
# @option arguments [String] :id The document ID
# @option arguments [String] :index The name of the index
# @option arguments [String] :type The type of the document; deprecated and optional starting with 7.0 *Deprecated*
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
# @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
# @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
Expand Down Expand Up @@ -61,14 +60,8 @@ def exists_source(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = OpenSearch::API::HTTP_HEAD
path = if _index && _type && _id
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
else
"#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
end
path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

body = nil
Expand Down
9 changes: 1 addition & 8 deletions opensearch-api/lib/opensearch/api/actions/explain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module Actions
#
# @option arguments [String] :id The document ID
# @option arguments [String] :index The name of the index
# @option arguments [String] :type The type of the document *Deprecated*
# @option arguments [Boolean] :analyze_wildcard Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
# @option arguments [String] :analyzer The analyzer for the query string query
# @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR)
Expand Down Expand Up @@ -65,19 +64,13 @@ def explain(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = if arguments[:body]
OpenSearch::API::HTTP_POST
else
OpenSearch::API::HTTP_GET
end

path = if _index && _type && _id
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_explain"
else
"#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}"
end
path = "#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}"
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

body = arguments[:body]
Expand Down
9 changes: 1 addition & 8 deletions opensearch-api/lib/opensearch/api/actions/get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module Actions
#
# @option arguments [String] :id The document ID
# @option arguments [String] :index The name of the index
# @option arguments [String] :type The type of the document (use `_all` to fetch the first document matching the ID across all types) *Deprecated*
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
# @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
Expand Down Expand Up @@ -62,14 +61,8 @@ def get(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = OpenSearch::API::HTTP_GET
path = if _index && _type && _id
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
else
"#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
end
path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

body = nil
Expand Down
9 changes: 1 addition & 8 deletions opensearch-api/lib/opensearch/api/actions/get_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module Actions
#
# @option arguments [String] :id The document ID
# @option arguments [String] :index The name of the index
# @option arguments [String] :type The type of the document; deprecated and optional starting with 7.0 *Deprecated*
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
# @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
# @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
Expand Down Expand Up @@ -61,14 +60,8 @@ def get_source(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = OpenSearch::API::HTTP_GET
path = if _index && _type && _id
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
else
"#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
end
path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

body = nil
Expand Down
9 changes: 1 addition & 8 deletions opensearch-api/lib/opensearch/api/actions/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module Actions
#
# @option arguments [String] :id Document ID
# @option arguments [String] :index The name of the index
# @option arguments [String] :type The type of the document *Deprecated*
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
# @option arguments [String] :op_type Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID (options: index, create)
# @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for)
Expand Down Expand Up @@ -64,15 +63,9 @@ def index(arguments = {})

_index = arguments.delete(:index)

_type = arguments.delete(:type)

method = _id ? OpenSearch::API::HTTP_PUT : OpenSearch::API::HTTP_POST
path = if _index && _type && _id
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
elsif _index && _id
path = if _index && _id
"#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
elsif _index && _type
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}"
else
"#{Utils.__listify(_index)}/_doc"
end
Expand Down
Loading