From 9d9834ae5605a787e62d303f5c91c5f14b30d615 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Fri, 22 Apr 2022 00:19:00 +0000 Subject: [PATCH 1/6] Test with unreleased OpenSearch Signed-off-by: Vacha Shah --- .github/workflows/main copy.yml | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/main copy.yml diff --git a/.github/workflows/main copy.yml b/.github/workflows/main copy.yml new file mode 100644 index 000000000..9641ad1e4 --- /dev/null +++ b/.github/workflows/main copy.yml @@ -0,0 +1,59 @@ +name: Integration with Unreleased OpenSearch + +on: + push: + branches: + - "main" + pull_request: + branches: + - "main" + +env: + OPENSEARCH_VERSION: '2.0' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + + - name: Checkout OpenSearch + uses: actions/checkout@v2 + with: + repository: opensearch-project/opensearch + ref: ${{ env.OPENSEARCH_VERSION }} + 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 \ No newline at end of file From 0ec48bf796e56990447c6d2a46c40b5d3f6898db Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Tue, 26 Apr 2022 06:31:52 +0000 Subject: [PATCH 2/6] Breaking changes for type removal Signed-off-by: Vacha Shah --- opensearch-api/README.md | 4 +- opensearch-api/lib/opensearch/api.rb | 2 +- .../lib/opensearch/api/actions/benchmark.rb | 1 - .../lib/opensearch/api/actions/bulk.rb | 8 +- .../lib/opensearch/api/actions/count.rb | 7 +- .../lib/opensearch/api/actions/create.rb | 1 - .../lib/opensearch/api/actions/delete.rb | 9 +- .../opensearch/api/actions/delete_by_query.rb | 9 +- .../lib/opensearch/api/actions/exists.rb | 9 +- .../opensearch/api/actions/exists_source.rb | 9 +- .../lib/opensearch/api/actions/explain.rb | 9 +- .../lib/opensearch/api/actions/get.rb | 9 +- .../lib/opensearch/api/actions/get_source.rb | 9 +- .../lib/opensearch/api/actions/index.rb | 9 +- .../api/actions/indices/exists_type.rb | 79 ------------ .../api/actions/indices/flush_synced.rb | 79 ------------ .../api/actions/indices/get_field_mapping.rb | 9 +- .../api/actions/indices/get_mapping.rb | 9 +- .../api/actions/indices/put_mapping.rb | 11 +- .../api/actions/indices/validate_query.rb | 7 +- .../lib/opensearch/api/actions/mget.rb | 9 +- .../lib/opensearch/api/actions/msearch.rb | 7 +- .../api/actions/msearch_template.rb | 7 +- .../opensearch/api/actions/mtermvectors.rb | 7 +- .../lib/opensearch/api/actions/search.rb | 8 +- .../opensearch/api/actions/search_template.rb | 7 +- .../lib/opensearch/api/actions/termvectors.rb | 9 +- .../lib/opensearch/api/actions/update.rb | 9 +- .../opensearch/api/actions/update_by_query.rb | 9 +- .../spec/opensearch/api/actions/bulk_spec.rb | 31 ++--- .../spec/opensearch/api/actions/count_spec.rb | 6 +- .../api/actions/create_document_spec.rb | 16 +-- .../api/actions/delete_by_query_spec.rb | 17 --- .../api/actions/delete_document_spec.rb | 20 +-- .../api/actions/exists_document_spec.rb | 20 +-- .../api/actions/explain_document_spec.rb | 16 +-- .../api/actions/get_document_source_spec.rb | 12 +- .../api/actions/get_document_spec.rb | 16 +-- .../api/actions/index_document_spec.rb | 24 ++-- .../api/actions/indices/exists_type_spec.rb | 117 ------------------ .../api/actions/indices/flush_synced_spec.rb | 99 --------------- .../actions/indices/get_field_mapping_spec.rb | 11 -- .../api/actions/indices/get_mapping_spec.rb | 21 +--- .../api/actions/indices/put_mapping_spec.rb | 29 ++--- .../actions/indices/validate_query_spec.rb | 10 -- .../spec/opensearch/api/actions/mget_spec.rb | 19 +-- .../api/actions/mtermvectors_spec.rb | 6 +- .../opensearch/api/actions/search_spec.rb | 21 +--- .../api/actions/termvectors_spec.rb | 10 +- .../api/actions/update_document_spec.rb | 22 ++-- .../spec/opensearch/transport/base_spec.rb | 2 +- .../spec/opensearch/transport/client_spec.rb | 6 +- 52 files changed, 145 insertions(+), 767 deletions(-) delete mode 100644 opensearch-api/lib/opensearch/api/actions/indices/exists_type.rb delete mode 100644 opensearch-api/lib/opensearch/api/actions/indices/flush_synced.rb delete mode 100644 opensearch-api/spec/opensearch/api/actions/indices/exists_type_spec.rb delete mode 100644 opensearch-api/spec/opensearch/api/actions/indices/flush_synced_spec.rb diff --git a/opensearch-api/README.md b/opensearch-api/README.md index 62f85c06e..5aedd3c11 100644 --- a/opensearch-api/README.md +++ b/opensearch-api/README.md @@ -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' } } }) @@ -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, ... }" ``` diff --git a/opensearch-api/lib/opensearch/api.rb b/opensearch-api/lib/opensearch/api.rb index 477908c70..29254595c 100644 --- a/opensearch-api/lib/opensearch/api.rb +++ b/opensearch-api/lib/opensearch/api.rb @@ -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, ... diff --git a/opensearch-api/lib/opensearch/api/actions/benchmark.rb b/opensearch-api/lib/opensearch/api/actions/benchmark.rb index 09f2e9b6b..153cafe10 100644 --- a/opensearch-api/lib/opensearch/api/actions/benchmark.rb +++ b/opensearch-api/lib/opensearch/api/actions/benchmark.rb @@ -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) diff --git a/opensearch-api/lib/opensearch/api/actions/bulk.rb b/opensearch-api/lib/opensearch/api/actions/bulk.rb index 159b31eef..29e833df6 100644 --- a/opensearch-api/lib/opensearch/api/actions/bulk.rb +++ b/opensearch-api/lib/opensearch/api/actions/bulk.rb @@ -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 @@ -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" @@ -85,7 +80,6 @@ def bulk(arguments = {}) :refresh, :routing, :timeout, - :type, :_source, :_source_excludes, :_source_includes, diff --git a/opensearch-api/lib/opensearch/api/actions/count.rb b/opensearch-api/lib/opensearch/api/actions/count.rb index 173a9d1cd..e20e57e1a 100644 --- a/opensearch-api/lib/opensearch/api/actions/count.rb +++ b/opensearch-api/lib/opensearch/api/actions/count.rb @@ -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) @@ -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" diff --git a/opensearch-api/lib/opensearch/api/actions/create.rb b/opensearch-api/lib/opensearch/api/actions/create.rb index 810215c47..1672dc841 100644 --- a/opensearch-api/lib/opensearch/api/actions/create.rb +++ b/opensearch-api/lib/opensearch/api/actions/create.rb @@ -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 diff --git a/opensearch-api/lib/opensearch/api/actions/delete.rb b/opensearch-api/lib/opensearch/api/actions/delete.rb index 22911e382..358d1dc2e 100644 --- a/opensearch-api/lib/opensearch/api/actions/delete.rb +++ b/opensearch-api/lib/opensearch/api/actions/delete.rb @@ -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 @@ -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 diff --git a/opensearch-api/lib/opensearch/api/actions/delete_by_query.rb b/opensearch-api/lib/opensearch/api/actions/delete_by_query.rb index c6cd4a2b8..7ebe09c23 100644 --- a/opensearch-api/lib/opensearch/api/actions/delete_by_query.rb +++ b/opensearch-api/lib/opensearch/api/actions/delete_by_query.rb @@ -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) @@ -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] diff --git a/opensearch-api/lib/opensearch/api/actions/exists.rb b/opensearch-api/lib/opensearch/api/actions/exists.rb index 69c2da82d..21acb5be5 100644 --- a/opensearch-api/lib/opensearch/api/actions/exists.rb +++ b/opensearch-api/lib/opensearch/api/actions/exists.rb @@ -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 @@ -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 diff --git a/opensearch-api/lib/opensearch/api/actions/exists_source.rb b/opensearch-api/lib/opensearch/api/actions/exists_source.rb index 84543799d..4259780e7 100644 --- a/opensearch-api/lib/opensearch/api/actions/exists_source.rb +++ b/opensearch-api/lib/opensearch/api/actions/exists_source.rb @@ -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 @@ -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 diff --git a/opensearch-api/lib/opensearch/api/actions/explain.rb b/opensearch-api/lib/opensearch/api/actions/explain.rb index 47074230b..cc32bd5e9 100644 --- a/opensearch-api/lib/opensearch/api/actions/explain.rb +++ b/opensearch-api/lib/opensearch/api/actions/explain.rb @@ -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) @@ -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] diff --git a/opensearch-api/lib/opensearch/api/actions/get.rb b/opensearch-api/lib/opensearch/api/actions/get.rb index bfa23d0e2..1271c9fb6 100644 --- a/opensearch-api/lib/opensearch/api/actions/get.rb +++ b/opensearch-api/lib/opensearch/api/actions/get.rb @@ -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 @@ -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 diff --git a/opensearch-api/lib/opensearch/api/actions/get_source.rb b/opensearch-api/lib/opensearch/api/actions/get_source.rb index 2a57ee831..9f9ab84c7 100644 --- a/opensearch-api/lib/opensearch/api/actions/get_source.rb +++ b/opensearch-api/lib/opensearch/api/actions/get_source.rb @@ -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 @@ -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 diff --git a/opensearch-api/lib/opensearch/api/actions/index.rb b/opensearch-api/lib/opensearch/api/actions/index.rb index 0c49ed4c5..82059bd3d 100644 --- a/opensearch-api/lib/opensearch/api/actions/index.rb +++ b/opensearch-api/lib/opensearch/api/actions/index.rb @@ -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) @@ -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 diff --git a/opensearch-api/lib/opensearch/api/actions/indices/exists_type.rb b/opensearch-api/lib/opensearch/api/actions/indices/exists_type.rb deleted file mode 100644 index 4cde59446..000000000 --- a/opensearch-api/lib/opensearch/api/actions/indices/exists_type.rb +++ /dev/null @@ -1,79 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Indices - module Actions - # Returns information about whether a particular document type exists. (DEPRECATED) - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` to check the types across all indices - # @option arguments [List] :type A comma-separated list of document types to check - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @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) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Hash] :headers Custom HTTP headers - # - # - def exists_type(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] - - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - _type = arguments.delete(:type) - - method = OpenSearch::API::HTTP_HEAD - path = "#{Utils.__listify(_index)}/_mapping/#{Utils.__listify(_type)}" - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 ? true : false - end - end - - alias_method :exists_type?, :exists_type - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:exists_type, [ - :ignore_unavailable, - :allow_no_indices, - :expand_wildcards, - :local - ].freeze) - end - end - end -end diff --git a/opensearch-api/lib/opensearch/api/actions/indices/flush_synced.rb b/opensearch-api/lib/opensearch/api/actions/indices/flush_synced.rb deleted file mode 100644 index 903447f46..000000000 --- a/opensearch-api/lib/opensearch/api/actions/indices/flush_synced.rb +++ /dev/null @@ -1,79 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module OpenSearch - module API - module Indices - module Actions - # Performs a synced flush operation on one or more indices. Synced flush is deprecated and will be removed in 8.0. Use flush instead - # - # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string for all indices - # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @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) - # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, none, all) - # @option arguments [Hash] :headers Custom HTTP headers - # - # *Deprecation notice*: - # Synced flush is deprecated and will be removed in 8.0. Use flush instead. - # Deprecated since version 7.6.0 - # - # - # - def flush_synced(arguments = {}) - headers = arguments.delete(:headers) || {} - - arguments = arguments.clone - - _index = arguments.delete(:index) - - method = OpenSearch::API::HTTP_POST - path = if _index - "#{Utils.__listify(_index)}/_flush/synced" - else - "_flush/synced" - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) - - body = nil - if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body } - else - perform_request(method, path, params, body, headers).body - end - end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:flush_synced, [ - :ignore_unavailable, - :allow_no_indices, - :expand_wildcards - ].freeze) - end - end - end -end diff --git a/opensearch-api/lib/opensearch/api/actions/indices/get_field_mapping.rb b/opensearch-api/lib/opensearch/api/actions/indices/get_field_mapping.rb index d621e7949..2cc90fd8f 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/get_field_mapping.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/get_field_mapping.rb @@ -32,7 +32,6 @@ module Actions # # @option arguments [List] :fields A comma-separated list of fields # @option arguments [List] :index A comma-separated list of index names - # @option arguments [List] :type A comma-separated list of document types *Deprecated* # @option arguments [Boolean] :include_type_name Whether a type should be returned in the body of the mappings. # @option arguments [Boolean] :include_defaults Whether the default mapping values should be returned as well # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -57,15 +56,9 @@ def get_field_mapping(arguments = {}) _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = OpenSearch::API::HTTP_GET - path = if _index && _type && _fields - "#{Utils.__listify(_index)}/_mapping/#{Utils.__listify(_type)}/field/#{Utils.__listify(_fields)}" - elsif _index && _fields + path = if _index && _fields "#{Utils.__listify(_index)}/_mapping/field/#{Utils.__listify(_fields)}" - elsif _type && _fields - "_mapping/#{Utils.__listify(_type)}/field/#{Utils.__listify(_fields)}" else "_mapping/field/#{Utils.__listify(_fields)}" end diff --git a/opensearch-api/lib/opensearch/api/actions/indices/get_mapping.rb b/opensearch-api/lib/opensearch/api/actions/indices/get_mapping.rb index 644c7dab2..3ed0a0ae5 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/get_mapping.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/get_mapping.rb @@ -31,7 +31,6 @@ module Actions # Returns mappings for one or more indices. # # @option arguments [List] :index A comma-separated list of index names - # @option arguments [List] :type A comma-separated list of document types *Deprecated* # @option arguments [Boolean] :include_type_name Whether to add the type name to the response (default: false) # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) # @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) @@ -53,15 +52,9 @@ def get_mapping(arguments = {}) _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = OpenSearch::API::HTTP_GET - path = if _index && _type - "#{Utils.__listify(_index)}/_mapping/#{Utils.__listify(_type)}" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_mapping" - elsif _type - "_mapping/#{Utils.__listify(_type)}" else "_mapping" end diff --git a/opensearch-api/lib/opensearch/api/actions/indices/put_mapping.rb b/opensearch-api/lib/opensearch/api/actions/indices/put_mapping.rb index 7dfc0e87d..26c08f078 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/put_mapping.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/put_mapping.rb @@ -31,7 +31,6 @@ module Actions # Updates the index mappings. # # @option arguments [List] :index A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - # @option arguments [String] :type The name of the document type *Deprecated* # @option arguments [Boolean] :include_type_name Whether a type should be expected in the body of the mappings. # @option arguments [Time] :timeout Explicit operation timeout # @option arguments [Time] :master_timeout Specify timeout for connection to master @@ -57,16 +56,8 @@ def put_mapping(arguments = {}) _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = OpenSearch::API::HTTP_PUT - path = if _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mappings" - elsif _index - "#{Utils.__listify(_index)}/_mappings" - elsif _type - "_mappings/#{Utils.__listify(_type)}" - end + path = "#{Utils.__listify(_index)}/_mappings" params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) body = arguments[:body] diff --git a/opensearch-api/lib/opensearch/api/actions/indices/validate_query.rb b/opensearch-api/lib/opensearch/api/actions/indices/validate_query.rb index 6881da65d..34eed0930 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/validate_query.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/validate_query.rb @@ -31,7 +31,6 @@ module Actions # Allows a user to validate a potentially expensive query without executing it. # # @option arguments [List] :index A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices - # @option arguments [List] :type A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types *Deprecated* # @option arguments [Boolean] :explain Return detailed information about the error # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) # @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) @@ -60,17 +59,13 @@ def validate_query(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 - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_validate/query" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_validate/query" else "_validate/query" diff --git a/opensearch-api/lib/opensearch/api/actions/mget.rb b/opensearch-api/lib/opensearch/api/actions/mget.rb index 48a6f69c4..e5614feef 100644 --- a/opensearch-api/lib/opensearch/api/actions/mget.rb +++ b/opensearch-api/lib/opensearch/api/actions/mget.rb @@ -30,7 +30,6 @@ module Actions # Allows to get multiple documents in one request. # # @option arguments [String] :index The name of the index - # @option arguments [String] :type The type of the document *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 @@ -40,7 +39,7 @@ module Actions # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. (*Required*) + # @option arguments [Hash] :body Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL. (*Required*) # # *Deprecation notice*: # Specifying types in urls has been deprecated @@ -57,12 +56,8 @@ def mget(arguments = {}) _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = OpenSearch::API::HTTP_POST - path = if _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mget" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_mget" else "_mget" diff --git a/opensearch-api/lib/opensearch/api/actions/msearch.rb b/opensearch-api/lib/opensearch/api/actions/msearch.rb index f72b22c86..68bc480f0 100644 --- a/opensearch-api/lib/opensearch/api/actions/msearch.rb +++ b/opensearch-api/lib/opensearch/api/actions/msearch.rb @@ -30,7 +30,6 @@ module Actions # Allows to execute several search operations in one request. # # @option arguments [List] :index A comma-separated list of index names to use as default - # @option arguments [List] :type A comma-separated list of document types to use as default # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) # @option arguments [Number] :max_concurrent_searches Controls the maximum number of concurrent searches the multi search api will execute # @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response @@ -56,12 +55,8 @@ def msearch(arguments = {}) _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = OpenSearch::API::HTTP_POST - path = if _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_msearch" else "_msearch" diff --git a/opensearch-api/lib/opensearch/api/actions/msearch_template.rb b/opensearch-api/lib/opensearch/api/actions/msearch_template.rb index 42d4ddad6..c18a5ba54 100644 --- a/opensearch-api/lib/opensearch/api/actions/msearch_template.rb +++ b/opensearch-api/lib/opensearch/api/actions/msearch_template.rb @@ -30,7 +30,6 @@ module Actions # Allows to execute several search template operations in one request. # # @option arguments [List] :index A comma-separated list of index names to use as default - # @option arguments [List] :type A comma-separated list of document types to use as default # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) # @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response # @option arguments [Number] :max_concurrent_searches Controls the maximum number of concurrent searches the multi search api will execute @@ -54,12 +53,8 @@ def msearch_template(arguments = {}) _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = OpenSearch::API::HTTP_POST - path = if _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch/template" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_msearch/template" else "_msearch/template" diff --git a/opensearch-api/lib/opensearch/api/actions/mtermvectors.rb b/opensearch-api/lib/opensearch/api/actions/mtermvectors.rb index 5110cbe05..c4e3177f6 100644 --- a/opensearch-api/lib/opensearch/api/actions/mtermvectors.rb +++ b/opensearch-api/lib/opensearch/api/actions/mtermvectors.rb @@ -30,7 +30,6 @@ module Actions # Returns multiple termvectors in one request. # # @option arguments [String] :index The index in which the document resides. - # @option arguments [String] :type The type of the document. # @option arguments [List] :ids A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body # @option arguments [Boolean] :term_statistics Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". # @option arguments [Boolean] :field_statistics Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". @@ -60,17 +59,13 @@ def mtermvectors(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 - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mtermvectors" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_mtermvectors" else "_mtermvectors" diff --git a/opensearch-api/lib/opensearch/api/actions/search.rb b/opensearch-api/lib/opensearch/api/actions/search.rb index 7a441422c..0cd825f8b 100644 --- a/opensearch-api/lib/opensearch/api/actions/search.rb +++ b/opensearch-api/lib/opensearch/api/actions/search.rb @@ -30,7 +30,6 @@ module Actions # Returns results matching a 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 - # @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 [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution @@ -87,21 +86,16 @@ def search(arguments = {}) headers = arguments.delete(:headers) || {} arguments = arguments.clone - arguments[:index] = UNDERSCORE_ALL if !arguments[:index] && arguments[:type] _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 - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_search" else "_search" diff --git a/opensearch-api/lib/opensearch/api/actions/search_template.rb b/opensearch-api/lib/opensearch/api/actions/search_template.rb index f77c7b45d..9dbcc1cb4 100644 --- a/opensearch-api/lib/opensearch/api/actions/search_template.rb +++ b/opensearch-api/lib/opensearch/api/actions/search_template.rb @@ -30,7 +30,6 @@ module Actions # Allows to use the Mustache language to pre-render a search definition. # # @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 - # @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types # @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) @@ -62,12 +61,8 @@ def search_template(arguments = {}) _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = OpenSearch::API::HTTP_POST - path = if _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search/template" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_search/template" else "_search/template" diff --git a/opensearch-api/lib/opensearch/api/actions/termvectors.rb b/opensearch-api/lib/opensearch/api/actions/termvectors.rb index 2614b28d8..ecedf9aa3 100644 --- a/opensearch-api/lib/opensearch/api/actions/termvectors.rb +++ b/opensearch-api/lib/opensearch/api/actions/termvectors.rb @@ -31,7 +31,6 @@ module Actions # # @option arguments [String] :index The index in which the document resides. (*Required*) # @option arguments [String] :id The id of the document, when not specified a doc param should be supplied. - # @option arguments [String] :type The type of the document. # @option arguments [Boolean] :term_statistics Specifies if total term frequency and document frequency should be returned. # @option arguments [Boolean] :field_statistics Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. # @option arguments [List] :fields A comma-separated list of fields to return. @@ -63,8 +62,6 @@ def termvectors(arguments = {}) _id = arguments.delete(:id) - _type = arguments.delete(:type) - method = if arguments[:body] OpenSearch::API::HTTP_POST else @@ -72,11 +69,7 @@ def termvectors(arguments = {}) end endpoint = arguments.delete(:endpoint) || '_termvectors' - path = if _index && _type && _id - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/#{endpoint}" - elsif _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{endpoint}" - elsif _index && _id + path = if _index && _id "#{Utils.__listify(_index)}/#{endpoint}/#{Utils.__listify(_id)}" else "#{Utils.__listify(_index)}/#{endpoint}" diff --git a/opensearch-api/lib/opensearch/api/actions/update.rb b/opensearch-api/lib/opensearch/api/actions/update.rb index 48197edd1..e4fc81c6e 100644 --- a/opensearch-api/lib/opensearch/api/actions/update.rb +++ b/opensearch-api/lib/opensearch/api/actions/update.rb @@ -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 update 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 [List] :_source True or false to return the _source field or not, or a list of fields to return # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field @@ -66,14 +65,8 @@ def update(arguments = {}) _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = OpenSearch::API::HTTP_POST - path = if _index && _type && _id - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_update" - else - "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}" - end + path = "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}" params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) body = arguments[:body] diff --git a/opensearch-api/lib/opensearch/api/actions/update_by_query.rb b/opensearch-api/lib/opensearch/api/actions/update_by_query.rb index 9bf01e5f8..8a3e07a03 100644 --- a/opensearch-api/lib/opensearch/api/actions/update_by_query.rb +++ b/opensearch-api/lib/opensearch/api/actions/update_by_query.rb @@ -31,7 +31,6 @@ module Actions # for example to pick up a mapping change. # # @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) @@ -85,14 +84,8 @@ def update_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)}/_update_by_query" - else - "#{Utils.__listify(_index)}/_update_by_query" - end + path = "#{Utils.__listify(_index)}/_update_by_query" params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) body = arguments[:body] diff --git a/opensearch-api/spec/opensearch/api/actions/bulk_spec.rb b/opensearch-api/spec/opensearch/api/actions/bulk_spec.rb index 689c6fefb..f61fdf2f1 100644 --- a/opensearch-api/spec/opensearch/api/actions/bulk_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/bulk_spec.rb @@ -47,22 +47,22 @@ let(:body) do <<-PAYLOAD.gsub(/^\s+/, '') - {"index":{"_index":"myindexA","_type":"mytype","_id":"1"}} + {"index":{"_index":"myindexA","_id":"1"}} {"title":"Test"} - {"update":{"_index":"myindexB","_type":"mytype","_id":"2"}} + {"update":{"_index":"myindexB","_id":"2"}} {"doc":{"title":"Update"}} - {"delete":{"_index":"myindexC","_type":"mytypeC","_id":"3"}} - {"index":{"_index":"myindexD","_type":"mytype","_id":"1"}} + {"delete":{"_index":"myindexC","_id":"3"}} + {"index":{"_index":"myindexD","_id":"1"}} {"data":"MYDATA"} PAYLOAD end it 'performs the request' do expect(client_double.bulk(:body => [ - { :index => { :_index => 'myindexA', :_type => 'mytype', :_id => '1', :data => { :title => 'Test' } } }, - { :update => { :_index => 'myindexB', :_type => 'mytype', :_id => '2', :data => { :doc => { :title => 'Update' } } } }, - { :delete => { :_index => 'myindexC', :_type => 'mytypeC', :_id => '3' } }, - { :index => { :_index => 'myindexD', :_type => 'mytype', :_id => '1', :data => { :data => 'MYDATA' } } }, + { :index => { :_index => 'myindexA', :_id => '1', :data => { :title => 'Test' } } }, + { :update => { :_index => 'myindexB', :_id => '2', :data => { :doc => { :title => 'Update' } } } }, + { :delete => { :_index => 'myindexC', :_id => '3' } }, + { :index => { :_index => 'myindexD', :_id => '1', :data => { :data => 'MYDATA' } } }, ])).to eq({}) end end @@ -80,13 +80,13 @@ let(:body) do <<-PAYLOAD.gsub(/^\s+/, '') - {"update":{"_index":"myindex","_type":"mytype","_id":"1"}} + {"update":{"_index":"myindex","_id":"1"}} {"doc":{"data":{"title":"Update"}}} PAYLOAD end it 'performs the request' do - expect(client_double.bulk(body:[ { :update => { :_index => 'myindex', :_type => 'mytype', :_id => '1' } }, + expect(client_double.bulk(body:[ { :update => { :_index => 'myindex', :_id => '1' } }, { :doc => { :data => { :title => 'Update' } } } ])).to eq({}) end end @@ -134,15 +134,4 @@ expect(client_double.bulk(index: 'foo^bar', body: [])).to eq({}) end end - - context 'when the type is provided' do - - let(:url) do - 'myindex/mytype/_bulk' - end - - it 'performs the request' do - expect(client_double.bulk(index: 'myindex', type: 'mytype', body: [])).to eq({}) - end - end end diff --git a/opensearch-api/spec/opensearch/api/actions/count_spec.rb b/opensearch-api/spec/opensearch/api/actions/count_spec.rb index 1b830ec60..213244782 100644 --- a/opensearch-api/spec/opensearch/api/actions/count_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/count_spec.rb @@ -42,12 +42,12 @@ expect(client_double.count).to eq({}) end - context 'when an index and type are specified' do + context 'when an index is specified' do let(:expected_args) do [ 'POST', - 'foo,bar/t1,t2/_count', + 'foo,bar/_count', {}, nil, {} @@ -55,7 +55,7 @@ end it 'performs the request' do - expect(client_double.count(index: ['foo','bar'], type: ['t1','t2'])).to eq({}) + expect(client_double.count(index: ['foo','bar'])).to eq({}) end end diff --git a/opensearch-api/spec/opensearch/api/actions/create_document_spec.rb b/opensearch-api/spec/opensearch/api/actions/create_document_spec.rb index b9f230cc8..89543ad86 100644 --- a/opensearch-api/spec/opensearch/api/actions/create_document_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/create_document_spec.rb @@ -31,7 +31,7 @@ let(:expected_args) do [ 'PUT', - 'foo/bar/123', + 'foo/_doc/123', { op_type: 'create' }, { foo: 'bar' }, {} @@ -39,7 +39,7 @@ end it 'performs the request' do - expect(client_double.create(index: 'foo', type: 'bar', id: '123', body: { foo: 'bar'})).to eq({}) + expect(client_double.create(index: 'foo', id: '123', body: { foo: 'bar'})).to eq({}) end context 'when the request needs to be URL-escaped' do @@ -47,7 +47,7 @@ let(:expected_args) do [ 'PUT', - 'foo/bar%2Fbam/123', + 'foo%5Ebar/_doc/123', { op_type: 'create' }, {}, {} @@ -55,7 +55,7 @@ end it 'performs the request' do - expect(client_double.create(index: 'foo', type: 'bar/bam', id: '123', body: {})).to eq({}) + expect(client_double.create(index: 'foo^bar', id: '123', body: {})).to eq({}) end end @@ -64,7 +64,7 @@ let(:expected_args) do [ 'PUT', - 'foo/bar/1', + 'foo/_doc/1', { op_type: 'create' }, { foo: 'bar' }, {} @@ -72,7 +72,7 @@ end it 'updates the arguments with the `op_type`' do - expect(client_double.create(index: 'foo', type: 'bar', id: 1, body: { foo: 'bar' })).to eq({}) + expect(client_double.create(index: 'foo', id: 1, body: { foo: 'bar' })).to eq({}) end end @@ -81,7 +81,7 @@ let(:expected_args) do [ 'POST', - 'foo/bar', + 'foo/_doc', { }, { foo: 'bar' }, {} @@ -89,7 +89,7 @@ end it 'updates the arguments with the `op_type`' do - expect(client_double.create(index: 'foo', type: 'bar', body: { foo: 'bar' })).to eq({}) + expect(client_double.create(index: 'foo', body: { foo: 'bar' })).to eq({}) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/delete_by_query_spec.rb b/opensearch-api/spec/opensearch/api/actions/delete_by_query_spec.rb index 5b7779c36..f2233db32 100644 --- a/opensearch-api/spec/opensearch/api/actions/delete_by_query_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/delete_by_query_spec.rb @@ -48,23 +48,6 @@ expect(client_double.delete_by_query(index: 'foo', body: { term: {} })).to eq({}) end - context 'when the type argument is provided' do - - let(:expected_args) do - [ - 'POST', - 'foo/tweet,post/_delete_by_query', - {}, - { term: {} }, - {} - ] - end - - it 'performs the request' do - expect(client_double.delete_by_query(index: 'foo', type: ['tweet', 'post'], body: { term: {} })).to eq({}) - end - end - context 'when a query is provided' do let(:expected_args) do [ diff --git a/opensearch-api/spec/opensearch/api/actions/delete_document_spec.rb b/opensearch-api/spec/opensearch/api/actions/delete_document_spec.rb index 562bc3f08..1dd5c1a9a 100644 --- a/opensearch-api/spec/opensearch/api/actions/delete_document_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/delete_document_spec.rb @@ -31,7 +31,7 @@ let(:expected_args) do [ 'DELETE', - 'foo/bar/1', + 'foo/_doc/1', params, nil, {} @@ -48,18 +48,18 @@ it 'requires the :index argument' do expect { - client.delete(type: 'bar', id: '1') + client.delete(id: '1') }.to raise_exception(ArgumentError) end it 'requires the :id argument' do expect { - client.delete(index: 'foo', type: 'bar') + client.delete(index: 'foo') }.to raise_exception(ArgumentError) end it 'performs the request' do - expect(client_double.delete(index: 'foo', type: 'bar', id: '1')).to eq({}) + expect(client_double.delete(index: 'foo', id: '1')).to eq({}) end context 'when url params are provided' do @@ -69,7 +69,7 @@ end it 'performs the request' do - expect(client_double.delete(index: 'foo', type: 'bar', id: '1', routing: 'abc123')).to eq({}) + expect(client_double.delete(index: 'foo', id: '1', routing: 'abc123')).to eq({}) end end @@ -77,7 +77,7 @@ it 'raises an ArgumentError' do expect { - client.delete(index: 'foo', type: 'bar', id: '1', qwertypoiuy: 'asdflkjhg') + client.delete(index: 'foo', id: '1', qwertypoiuy: 'asdflkjhg') }.to raise_exception(ArgumentError) end end @@ -87,7 +87,7 @@ let(:expected_args) do [ 'DELETE', - 'foo%5Ebar/bar%2Fbam/1', + 'foo%5Ebar/_doc/1', params, nil, {} @@ -95,7 +95,7 @@ end it 'escapes the url params' do - expect(client_double.delete(index: 'foo^bar', type: 'bar/bam', id: 1)).to eq({}) + expect(client_double.delete(index: 'foo^bar', id: 1)).to eq({}) end end @@ -107,14 +107,14 @@ it 'raises the exception' do expect { - client.delete(index: 'foo', type: 'bar', id: 'XXX') + client.delete(index: 'foo', id: 'XXX') }.to raise_exception(NotFound) end context 'when the :ignore option is provided' do it 'does not raise the NotFound exception' do - expect(client.delete(index: 'foo', type: 'bar', id: 1, ignore: 404)).to eq(false) + expect(client.delete(index: 'foo', id: 1, ignore: 404)).to eq(false) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/exists_document_spec.rb b/opensearch-api/spec/opensearch/api/actions/exists_document_spec.rb index 7c6e0341e..6b1a61413 100644 --- a/opensearch-api/spec/opensearch/api/actions/exists_document_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/exists_document_spec.rb @@ -43,7 +43,7 @@ end let(:url) do - 'foo/bar/1' + 'foo/_doc/1' end let(:client) do @@ -52,13 +52,13 @@ it 'requires the :index argument' do expect { - client.exists(type: 'bar', id: '1') + client.exists(id: '1') }.to raise_exception(ArgumentError) end it 'requires the :id argument' do expect { - client.exists(index: 'foo', type: 'bar') + client.exists(index: 'foo') }.to raise_exception(ArgumentError) end @@ -74,7 +74,7 @@ end it 'is aliased to a predicated method' do - expect(client_double.exists?(index: 'foo', type: 'bar', id: '1')).to eq(true) + expect(client_double.exists?(index: 'foo', id: '1')).to eq(true) end context 'when URL parameters are provided' do @@ -84,18 +84,18 @@ end it 'passes the parameters' do - expect(client_double.exists(index: 'foo', type: 'bar', id: '1', routing: 'abc123')).to eq(true) + expect(client_double.exists(index: 'foo', id: '1', routing: 'abc123')).to eq(true) end end context 'when the request needs to be URL-escaped' do let(:url) do - 'foo/bar%2Fbam/1' + 'foo%5Ebar/_doc/1' end it 'URL-escapes the characters' do - expect(client_double.exists(index: 'foo', type: 'bar/bam', id: '1')).to eq(true) + expect(client_double.exists(index: 'foo^bar', id: '1')).to eq(true) end end @@ -106,7 +106,7 @@ end it 'returns false' do - expect(client_double.exists(index: 'foo', type: 'bar', id: '1')).to eq(false) + expect(client_double.exists(index: 'foo', id: '1')).to eq(false) end end @@ -117,7 +117,7 @@ end it 'returns false' do - expect(client_double.exists(index: 'foo', type: 'bar', id: '1')).to eq(false) + expect(client_double.exists(index: 'foo', id: '1')).to eq(false) end end @@ -129,7 +129,7 @@ it 'raises the error' do expect { - client_double.exists(index: 'foo', type: 'bar', id: '1') + client_double.exists(index: 'foo', id: '1') }.to raise_exception(StandardError) end end diff --git a/opensearch-api/spec/opensearch/api/actions/explain_document_spec.rb b/opensearch-api/spec/opensearch/api/actions/explain_document_spec.rb index cc8ffe78d..5bf5f37bd 100644 --- a/opensearch-api/spec/opensearch/api/actions/explain_document_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/explain_document_spec.rb @@ -48,7 +48,7 @@ end let(:url) do - 'foo/bar/1/_explain' + 'foo/_explain/1' end let(:client) do @@ -57,18 +57,18 @@ it 'requires the :index argument' do expect { - client.explain(type: 'bar', id: '1') + client.explain(id: '1') }.to raise_exception(ArgumentError) end it 'requires the :id argument' do expect { - client.explain(index: 'foo', type: 'bar') + client.explain(index: 'foo') }.to raise_exception(ArgumentError) end it 'performs the request' do - expect(client_double.explain(index: 'foo', type: 'bar', id: 1, body: {})).to eq({}) + expect(client_double.explain(index: 'foo', id: 1, body: {})).to eq({}) end context 'when a query is provided' do @@ -82,7 +82,7 @@ end it 'passes the query' do - expect(client_double.explain(index: 'foo', type: 'bar', id: '1', q: 'abc123')).to eq({}) + expect(client_double.explain(index: 'foo', id: '1', q: 'abc123')).to eq({}) end end @@ -92,17 +92,17 @@ end it 'passes the query definition' do - expect(client_double.explain(index: 'foo', type: 'bar', id: '1', body: { query: { match: {} } })).to eq({}) + expect(client_double.explain(index: 'foo', id: '1', body: { query: { match: {} } })).to eq({}) end end context 'when the request needs to be URL-escaped' do let(:url) do - 'foo%5Ebar/bar%2Fbam/1/_explain' + 'foo%5Ebar/_explain/1' end it 'URL-escapes the parts' do - expect(client_double.explain(index: 'foo^bar', type: 'bar/bam', id: '1', body: { })).to eq({}) + expect(client_double.explain(index: 'foo^bar', id: '1', body: { })).to eq({}) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/get_document_source_spec.rb b/opensearch-api/spec/opensearch/api/actions/get_document_source_spec.rb index b54f627b0..873c2684b 100644 --- a/opensearch-api/spec/opensearch/api/actions/get_document_source_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/get_document_source_spec.rb @@ -43,7 +43,7 @@ end let(:url) do - 'foo/bar/1/_source' + 'foo/_source/1' end let(:client) do @@ -52,13 +52,13 @@ it 'requires the :index argument' do expect { - client.get_source(type: 'bar', id: '1') + client.get_source(id: '1') }.to raise_exception(ArgumentError) end it 'requires the :id argument' do expect { - client.get_source(index: 'foo', type: 'bar') + client.get_source(index: 'foo') }.to raise_exception(ArgumentError) end @@ -80,18 +80,18 @@ end it 'Passes the URL params' do - expect(client_double.get_source(index: 'foo', type: 'bar', id: '1', routing: 'abc123')).to eq({}) + expect(client_double.get_source(index: 'foo', id: '1', routing: 'abc123')).to eq({}) end end context 'when the request needs to be URL-escaped' do let(:url) do - 'foo%5Ebar/bar%2Fbam/1/_source' + 'foo%5Ebar/_source/1' end it 'URL-escapes the parts' do - expect(client_double.get_source(index: 'foo^bar', type: 'bar/bam', id: '1')).to eq({}) + expect(client_double.get_source(index: 'foo^bar', id: '1')).to eq({}) end end diff --git a/opensearch-api/spec/opensearch/api/actions/get_document_spec.rb b/opensearch-api/spec/opensearch/api/actions/get_document_spec.rb index 1c440ebcd..feba187fe 100644 --- a/opensearch-api/spec/opensearch/api/actions/get_document_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/get_document_spec.rb @@ -43,7 +43,7 @@ end let(:url) do - 'foo/bar/1' + 'foo/_doc/1' end let(:client) do @@ -52,13 +52,13 @@ it 'requires the :index argument' do expect { - client.get(type: 'bar', id: '1') + client.get(id: '1') }.to raise_exception(ArgumentError) end it 'requires the :id argument' do expect { - client.get(index: 'foo', type: 'bar') + client.get(index: 'foo') }.to raise_exception(ArgumentError) end @@ -80,7 +80,7 @@ end it 'Passes the URL params' do - expect(client_double.get(index: 'foo', type: 'bar', id: '1', routing: 'abc123')).to eq({}) + expect(client_double.get(index: 'foo', id: '1', routing: 'abc123')).to eq({}) end end @@ -88,7 +88,7 @@ it 'Passes the URL params' do expect { - client.get(index: 'foo', type: 'bar', id: '1', qwert: 'abc123') + client.get(index: 'foo', id: '1', qwert: 'abc123') }.to raise_exception(ArgumentError) end end @@ -96,11 +96,11 @@ context 'when the request needs to be URL-escaped' do let(:url) do - 'foo%5Ebar/bar%2Fbam/1' + 'foo%5Ebar/_doc/1' end it 'URL-escapes the parts' do - expect(client_double.get(index: 'foo^bar', type: 'bar/bam', id: '1')).to eq({}) + expect(client_double.get(index: 'foo^bar', id: '1')).to eq({}) end end @@ -125,7 +125,7 @@ end it 'returns false' do - expect(client.get(index: 'foo', type: 'bar', id: '1', ignore: 404)).to eq(false) + expect(client.get(index: 'foo', id: '1', ignore: 404)).to eq(false) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/index_document_spec.rb b/opensearch-api/spec/opensearch/api/actions/index_document_spec.rb index 1ee73b5b4..6f9c60f52 100644 --- a/opensearch-api/spec/opensearch/api/actions/index_document_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/index_document_spec.rb @@ -47,7 +47,7 @@ end let(:url) do - 'foo/bar' + 'foo/_doc' end let(:body) do @@ -60,12 +60,12 @@ it 'requires the :index argument' do expect { - client.index(type: 'bar') + client.index() }.to raise_exception(ArgumentError) end it 'performs the request' do - expect(client_double.index(index: 'foo', type: 'bar', body: body)).to eq({}) + expect(client_double.index(index: 'foo', body: body)).to eq({}) end context 'when a specific id is provided' do @@ -75,11 +75,11 @@ end let(:url) do - 'foo/bar/1' + 'foo/_doc/1' end it 'performs the request' do - expect(client_double.index(index: 'foo', type: 'bar', id: '1', body: body)).to eq({}) + expect(client_double.index(index: 'foo', id: '1', body: body)).to eq({}) end end @@ -90,7 +90,7 @@ end let(:url) do - 'foo/bar' + 'foo/_doc' end let(:params) do @@ -98,7 +98,7 @@ end it 'passes the URL params' do - expect(client_double.index(index: 'foo', type: 'bar', op_type: 'create', body: body)).to eq({}) + expect(client_double.index(index: 'foo', op_type: 'create', body: body)).to eq({}) end context 'when a specific id is provided' do @@ -108,7 +108,7 @@ end let(:url) do - 'foo/bar/1' + 'foo/_doc/1' end let(:params) do @@ -116,7 +116,7 @@ end it 'passes the URL params' do - expect(client_double.index(index: 'foo', type: 'bar', id: '1', op_type: 'create', body: body)).to eq({}) + expect(client_double.index(index: 'foo', id: '1', op_type: 'create', body: body)).to eq({}) end end end @@ -127,11 +127,11 @@ end let(:url) do - 'foo/bar%2Fbam/123' + 'foo%5Ebar/_doc/123' end it 'URL-escapes the parts' do - expect(client_double.index(index: 'foo', type: 'bar/bam', id: '123', body: body)).to eq({}) + expect(client_double.index(index: 'foo^bar', id: '123', body: body)).to eq({}) end end @@ -139,7 +139,7 @@ it 'raises and ArgumentError' do expect { - client.index(index: 'foo', type: 'bar', id: '1', qwerty: 'yuiop') + client.index(index: 'foo', id: '1', qwerty: 'yuiop') }.to raise_exception(ArgumentError) end end diff --git a/opensearch-api/spec/opensearch/api/actions/indices/exists_type_spec.rb b/opensearch-api/spec/opensearch/api/actions/indices/exists_type_spec.rb deleted file mode 100644 index 5bba418f3..000000000 --- a/opensearch-api/spec/opensearch/api/actions/indices/exists_type_spec.rb +++ /dev/null @@ -1,117 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require 'spec_helper' - -describe 'client.indices#exists_type' do - - let(:expected_args) do - [ - 'HEAD', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo/_mapping/bar' - end - - it 'performs the request' do - expect(client_double.indices.exists_type(index: 'foo', type: 'bar')).to eq(true) - end - - it 'aliased to a predicate method' do - expect(client_double.indices.exists_type?(index: 'foo', type: 'bar')).to eq(true) - end - - context 'when multiple indices are specified' do - - let(:url) do - 'foo,bar/_mapping/bam' - end - - it 'performs the request' do - expect(client_double.indices.exists_type(index: ['foo','bar'], type: 'bam')).to eq(true) - end - end - - context 'when the path needs to be URL-escaped' do - - let(:url) do - 'foo%5Ebar/_mapping/bar%2Fbam' - end - - it 'performs the request' do - expect(client_double.indices.exists_type(index: 'foo^bar', type: 'bar/bam')).to eq(true) - end - end - - context 'when 404 response is received' do - - let(:response_double) do - double('response', status: 404, body: {}, headers: {}) - end - - it 'returns false' do - expect(client_double.indices.exists_type(index: 'foo', type: 'bar')).to eq(false) - end - end - - context 'when a \'not found\' exception is raised' do - - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new('404 Not Found')) - end - end - - it 'returns false' do - expect(client.indices.exists_type(index: 'foo', type: 'bar')).to eq(false) - end - end - - context 'when a generic exception is raised' do - - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new) - end - end - - it 'raises the exception' do - expect { - client.indices.exists_type(index: 'foo', type: 'bar') - }.to raise_exception(StandardError) - end - end -end diff --git a/opensearch-api/spec/opensearch/api/actions/indices/flush_synced_spec.rb b/opensearch-api/spec/opensearch/api/actions/indices/flush_synced_spec.rb deleted file mode 100644 index 0f64c7576..000000000 --- a/opensearch-api/spec/opensearch/api/actions/indices/flush_synced_spec.rb +++ /dev/null @@ -1,99 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require 'spec_helper' - -describe 'client.indices#flush_synced' do - - let(:expected_args) do - [ - 'POST', - url, - params, - nil, - {} - ] - end - - let(:params) do - {} - end - - let(:url) do - 'foo/_flush/synced' - end - - it 'performs the request' do - expect(client_double.indices.flush_synced(index: 'foo')).to eq({}) - end - - context 'when a \'not found\' exception is raised' do - - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(NotFound) - end - end - - it 'raises the exception' do - expect { - client.indices.flush_synced(index: 'foo') - }.to raise_exception(NotFound) - end - end - - context 'when a \'not found\' exception is raised' do - - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(NotFound) - end - end - - it 'raises the exception' do - expect { - client.indices.flush_synced(index: 'foo') - }.to raise_exception(NotFound) - end - end - - context 'when the ignore parameter is specified' do - - let(:client) do - Class.new { include OpenSearch::API }.new.tap do |_client| - expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new('404 Not Found')) - end - end - - let(:params) do - { ignore: 404 } - end - - it 'does not raise the exception' do - expect(client.indices.flush_synced(index: 'foo', ignore: 404)).to eq(false) - end - end -end diff --git a/opensearch-api/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb b/opensearch-api/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb index 6ecad1246..1071af6a8 100644 --- a/opensearch-api/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb @@ -56,15 +56,4 @@ expect(client_double.indices.get_field_mapping(index: 'foo', field: 'bam')).to eq({}) end end - - context 'when a type is specified' do - - let(:url) do - 'foo/_mapping/bar/field/bam' - end - - it 'performs the request' do - expect(client_double.indices.get_field_mapping(index: 'foo', type: 'bar', field: 'bam')).to eq({}) - end - end end diff --git a/opensearch-api/spec/opensearch/api/actions/indices/get_mapping_spec.rb b/opensearch-api/spec/opensearch/api/actions/indices/get_mapping_spec.rb index 8ee3ea040..1d814d077 100644 --- a/opensearch-api/spec/opensearch/api/actions/indices/get_mapping_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/indices/get_mapping_spec.rb @@ -57,36 +57,25 @@ end end - context 'when an index and type are specified' do + context 'when multiple indices are specified' do let(:url) do - 'foo/_mapping/bar' + 'foo,bar/_mapping' end it 'performs the request' do - expect(client_double.indices.get_mapping(index: 'foo', type: 'bar')).to eq({}) - end - end - - context 'when multiple indices and types are specified' do - - let(:url) do - 'foo,bar/_mapping/bam,baz' - end - - it 'performs the request' do - expect(client_double.indices.get_mapping(index: ['foo', 'bar'], type: ['bam', 'baz'])).to eq({}) + expect(client_double.indices.get_mapping(index: ['foo', 'bar'])).to eq({}) end end context 'when the path must be URL-escaped' do let(:url) do - 'foo%5Ebar/_mapping/bar%2Fbam' + 'foo%5Ebar/_mapping' end it 'performs the request' do - expect(client_double.indices.get_mapping(index: 'foo^bar', type: 'bar/bam')).to eq({}) + expect(client_double.indices.get_mapping(index: 'foo^bar')).to eq({}) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/indices/put_mapping_spec.rb b/opensearch-api/spec/opensearch/api/actions/indices/put_mapping_spec.rb index fa4d15cc5..bca2ebccf 100644 --- a/opensearch-api/spec/opensearch/api/actions/indices/put_mapping_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/indices/put_mapping_spec.rb @@ -39,7 +39,7 @@ end let(:url) do - 'foo/bar/_mappings' + 'foo/_mappings' end let(:body) do @@ -47,20 +47,7 @@ end it 'performs the request' do - expect(client_double.indices.put_mapping(index: 'foo', type: 'bar', body: {})).to eq({}) - end - - context 'when there is no type specified' do - - let(:client) do - Class.new { include OpenSearch::API }.new - end - - it 'raises an exception' do - expect { - client.indices.put_mapping(type: 'foo') - }.to raise_exception(ArgumentError) - end + expect(client_double.indices.put_mapping(index: 'foo', body: {})).to eq({}) end context 'when there is no body specified' do @@ -71,7 +58,7 @@ it 'raises an exception' do expect { - client.indices.put_mapping(index: 'foo', type: 'bar') + client.indices.put_mapping(index: 'foo') }.to raise_exception(ArgumentError) end end @@ -83,29 +70,29 @@ end it 'performs the request' do - expect(client_double.indices.put_mapping(index: 'foo', type: 'bar', body: { filter: 'foo' })).to eq({}) + expect(client_double.indices.put_mapping(index: 'foo', body: { filter: 'foo' })).to eq({}) end end context 'when multiple indices are specified' do let(:url) do - 'foo,bar/bam/_mappings' + 'foo,bar/_mappings' end it 'performs the request' do - expect(client_double.indices.put_mapping(index: ['foo','bar'], type: 'bam', body: {})).to eq({}) + expect(client_double.indices.put_mapping(index: ['foo','bar'], body: {})).to eq({}) end end context 'when the path needs to be URL-escaped' do let(:url) do - 'foo%5Ebar/bar%2Fbam/_mappings' + 'foo%5Ebar/_mappings' end it 'performs the request' do - expect(client_double.indices.put_mapping(index: 'foo^bar', type: 'bar/bam', body: {})).to eq({}) + expect(client_double.indices.put_mapping(index: 'foo^bar', body: {})).to eq({}) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/indices/validate_query_spec.rb b/opensearch-api/spec/opensearch/api/actions/indices/validate_query_spec.rb index 56c5f0b7e..583d0711c 100644 --- a/opensearch-api/spec/opensearch/api/actions/indices/validate_query_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/indices/validate_query_spec.rb @@ -64,16 +64,6 @@ end end - context 'when a type and index are specified' do - let(:url) do - 'foo/bar/_validate/query' - end - - it 'performs the request' do - expect(client_double.indices.validate_query(index: 'foo', type: 'bar')).to eq({}) - end - end - context 'when multiple indicies are specified as a list' do let(:url) do 'foo,bar/_validate/query' diff --git a/opensearch-api/spec/opensearch/api/actions/mget_spec.rb b/opensearch-api/spec/opensearch/api/actions/mget_spec.rb index 82416dcb7..b66025f79 100644 --- a/opensearch-api/spec/opensearch/api/actions/mget_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/mget_spec.rb @@ -64,21 +64,6 @@ end end - context 'when a type is specified' do - - let(:url) do - 'foo/bar/_mget' - end - - let(:body) do - { ids: [ '1', '2' ]} - end - - it 'performs the request' do - expect(client_double.mget(index: 'foo', type: 'bar', body: { :ids => [ '1', '2'] })).to eq({}) - end - end - context 'when url parameters are provided' do let(:params) do @@ -97,7 +82,7 @@ context 'when the request needs to be URL-escaped' do let(:url) do - 'foo%5Ebar/bar%2Fbam/_mget' + 'foo%5Ebar/_mget' end let(:body) do @@ -105,7 +90,7 @@ end it 'performs the request' do - expect(client_double.mget(index: 'foo^bar', type: 'bar/bam', body: { :ids => [ '1', '2'] })).to eq({}) + expect(client_double.mget(index: 'foo^bar', body: { :ids => [ '1', '2'] })).to eq({}) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/mtermvectors_spec.rb b/opensearch-api/spec/opensearch/api/actions/mtermvectors_spec.rb index 30f428a64..77660a368 100644 --- a/opensearch-api/spec/opensearch/api/actions/mtermvectors_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/mtermvectors_spec.rb @@ -30,7 +30,7 @@ let(:expected_args) do [ method, - 'my-index/my-type/_mtermvectors', + 'my-index/_mtermvectors', {}, body, {} @@ -43,13 +43,13 @@ end it 'performs the request' do - expect(client_double.mtermvectors(index: 'my-index', type: 'my-type', body: { ids: [1, 2, 3] })).to eq({}) + expect(client_double.mtermvectors(index: 'my-index', body: { ids: [1, 2, 3] })).to eq({}) end context 'when a list of ids is passed instead of a body' do let(:method) { 'GET' } it 'performs the request' do - expect(client_double.mtermvectors(index: 'my-index', type: 'my-type', ids: [1, 2, 3])).to eq({}) + expect(client_double.mtermvectors(index: 'my-index', ids: [1, 2, 3])).to eq({}) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/search_spec.rb b/opensearch-api/spec/opensearch/api/actions/search_spec.rb index 31e31a8ad..b31ab1bd9 100644 --- a/opensearch-api/spec/opensearch/api/actions/search_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/search_spec.rb @@ -47,11 +47,11 @@ end let(:url) do - '_all/foo/_search' + '_search' end it 'has a default value for index' do - expect(client_double.search(type: 'foo')) + expect(client_double.search()) end context 'when a request definition is specified' do @@ -80,14 +80,14 @@ end end - context 'when an index and type are specified' do + context 'when an index is specified' do let(:url) do - 'foo/bar/_search' + 'foo/_search' end it 'performs the request' do - expect(client_double.search(index: 'foo', type: 'bar')) + expect(client_double.search(index: 'foo')) end end @@ -102,17 +102,6 @@ end end - context 'when multiple indices and types are specified' do - - let(:url) do - 'foo,bar/lam,bam/_search' - end - - it 'performs the request' do - expect(client_double.search(index: ['foo', 'bar'], type: ['lam', 'bam'])) - end - end - context 'when there are URL params' do let(:url) do diff --git a/opensearch-api/spec/opensearch/api/actions/termvectors_spec.rb b/opensearch-api/spec/opensearch/api/actions/termvectors_spec.rb index 6f52d48a6..90a830e30 100644 --- a/opensearch-api/spec/opensearch/api/actions/termvectors_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/termvectors_spec.rb @@ -38,7 +38,7 @@ end let(:url) do - 'foo/bar/123/_termvectors' + 'foo/_termvectors/123' end let(:params) do @@ -55,21 +55,21 @@ it 'requires the :index argument' do expect { - client.termvectors(type: 'bar', id: '1') + client.termvectors(id: '1') }.to raise_exception(ArgumentError) end it 'performs the request' do - expect(client_double.termvectors(index: 'foo', type: 'bar', id: '123', body: {})).to eq({}) + expect(client_double.termvectors(index: 'foo', id: '123', body: {})).to eq({}) end context 'when the older api name \'termvector\' is used' do let(:url) do - 'foo/bar/123/_termvector' + 'foo/_termvector/123' end it 'performs the request' do - expect(client_double.termvector(index: 'foo', type: 'bar', id: '123', body: {})).to eq({}) + expect(client_double.termvector(index: 'foo', id: '123', body: {})).to eq({}) end end end diff --git a/opensearch-api/spec/opensearch/api/actions/update_document_spec.rb b/opensearch-api/spec/opensearch/api/actions/update_document_spec.rb index 28e7e1162..8e142ebc7 100644 --- a/opensearch-api/spec/opensearch/api/actions/update_document_spec.rb +++ b/opensearch-api/spec/opensearch/api/actions/update_document_spec.rb @@ -43,7 +43,7 @@ end let(:url) do - 'foo/bar/1/_update' + 'foo/_update/1' end let(:client) do @@ -56,24 +56,24 @@ it 'requires the :index argument' do expect { - client.update(type: 'bar', id: '1') + client.update(id: '1') }.to raise_exception(ArgumentError) end it 'requires the :id argument' do expect { - client.update(index: 'foo', type: 'bar') + client.update(index: 'foo') }.to raise_exception(ArgumentError) end it 'performs the request' do - expect(client_double.update(index: 'foo', type: 'bar', id: '1', body: { doc: {} })).to eq({}) + expect(client_double.update(index: 'foo', id: '1', body: { doc: {} })).to eq({}) end context 'when URL parameters are provided' do let(:url) do - 'foo/bar/1/_update' + 'foo/_update/1' end let(:body) do @@ -81,7 +81,7 @@ end it 'performs the request' do - expect(client_double.update(index: 'foo', type: 'bar', id: '1', body: {})) + expect(client_double.update(index: 'foo', id: '1', body: {})) end end @@ -89,7 +89,7 @@ it 'raises an ArgumentError' do expect { - client.update(index: 'foo', type: 'bar', id: '1', body: { doc: {} }, qwertypoiuy: 'asdflkjhg') + client.update(index: 'foo', id: '1', body: { doc: {} }, qwertypoiuy: 'asdflkjhg') }.to raise_exception(ArgumentError) end end @@ -97,7 +97,7 @@ context 'when the request needs to be URL-escaped' do let(:url) do - 'foo%5Ebar/bar%2Fbam/1/_update' + 'foo%5Ebar/_update/1' end let(:body) do @@ -105,7 +105,7 @@ end it 'escapes the parts' do - expect(client_double.update(index: 'foo^bar', type: 'bar/bam', id: '1', body: {})) + expect(client_double.update(index: 'foo^bar', id: '1', body: {})) end end @@ -117,14 +117,14 @@ it 'raises it to the user' do expect { - client.update(index: 'foo', type: 'bar', id: 'XXX', body: {}) + client.update(index: 'foo', id: 'XXX', body: {}) }.to raise_exception(NotFound) end context 'when the :ignore parameter is specified' do it 'does not raise the error to the user' do - expect(client.update(index: 'foo', type: 'bar', id: 'XXX', body: {}, ignore: 404)).to eq(false) + expect(client.update(index: 'foo', id: 'XXX', body: {}, ignore: 404)).to eq(false) end end end diff --git a/opensearch-transport/spec/opensearch/transport/base_spec.rb b/opensearch-transport/spec/opensearch/transport/base_spec.rb index f1d2d0f7e..f04600e9e 100644 --- a/opensearch-transport/spec/opensearch/transport/base_spec.rb +++ b/opensearch-transport/spec/opensearch/transport/base_spec.rb @@ -184,7 +184,7 @@ it 'retries on 404 status the specified number of max_retries' do expect do - client.transport.perform_request('GET', 'myindex/mydoc/1?routing=FOOBARBAZ', {}, nil, nil, retry_on_failure: 5) + client.transport.perform_request('GET', 'myindex/_doc/1?routing=FOOBARBAZ', {}, nil, nil, retry_on_failure: 5) end.to raise_exception(OpenSearch::Transport::Transport::Errors::NotFound) end end diff --git a/opensearch-transport/spec/opensearch/transport/client_spec.rb b/opensearch-transport/spec/opensearch/transport/client_spec.rb index b20071a7d..0888e3ec0 100644 --- a/opensearch-transport/spec/opensearch/transport/client_spec.rb +++ b/opensearch-transport/spec/opensearch/transport/client_spec.rb @@ -1680,12 +1680,12 @@ client.perform_request('DELETE', '_all') client.perform_request('DELETE', 'myindex') rescue client.perform_request('PUT', 'myindex', {}, { settings: { number_of_shards: 2, number_of_replicas: 0 } }) - client.perform_request('PUT', 'myindex/mydoc/1', { routing: 'XYZ', timeout: '1s' }, { foo: 'bar' }) + client.perform_request('PUT', 'myindex/_doc/1', { routing: 'XYZ', timeout: '1s' }, { foo: 'bar' }) client.perform_request('GET', '_cluster/health?wait_for_status=green&timeout=2s', {}) end let(:response) do - client.perform_request('GET', 'myindex/mydoc/1?routing=XYZ') + client.perform_request('GET', 'myindex/_doc/1?routing=XYZ') end it 'handles paths and URL paramters' do @@ -1700,7 +1700,7 @@ context 'when an invalid url is specified' do it 'raises an exception' do expect { - client.perform_request('GET', 'myindex/mydoc/1?routing=FOOBARBAZ') + client.perform_request('GET', 'myindex/_doc/1?routing=FOOBARBAZ') }.to raise_exception(OpenSearch::Transport::Transport::Errors::NotFound) end end From d6bc42cf9ac2bc9ccf497daaceb87bb1917aae70 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Tue, 26 Apr 2022 18:51:20 +0000 Subject: [PATCH 3/6] Removing include_type_name parameter Signed-off-by: Vacha Shah --- opensearch-api/lib/opensearch/api/actions/indices/create.rb | 2 -- opensearch-api/lib/opensearch/api/actions/indices/get.rb | 2 -- .../lib/opensearch/api/actions/indices/get_field_mapping.rb | 2 -- .../lib/opensearch/api/actions/indices/get_mapping.rb | 2 -- .../lib/opensearch/api/actions/indices/get_template.rb | 2 -- .../lib/opensearch/api/actions/indices/put_mapping.rb | 2 -- .../lib/opensearch/api/actions/indices/put_template.rb | 2 -- opensearch-api/lib/opensearch/api/actions/indices/rollover.rb | 2 -- 8 files changed, 16 deletions(-) diff --git a/opensearch-api/lib/opensearch/api/actions/indices/create.rb b/opensearch-api/lib/opensearch/api/actions/indices/create.rb index 187619e16..6cf46469f 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/create.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/create.rb @@ -31,7 +31,6 @@ module Actions # Creates an index with optional settings and mappings. # # @option arguments [String] :index The name of the index - # @option arguments [Boolean] :include_type_name Whether a type should be expected in the body of the mappings. # @option arguments [String] :wait_for_active_shards Set the number of active shards to wait for before the operation returns. # @option arguments [Time] :timeout Explicit operation timeout # @option arguments [Time] :master_timeout Specify timeout for connection to master @@ -60,7 +59,6 @@ def create(arguments = {}) # # @since 6.2.0 ParamsRegistry.register(:create, [ - :include_type_name, :wait_for_active_shards, :timeout, :master_timeout diff --git a/opensearch-api/lib/opensearch/api/actions/indices/get.rb b/opensearch-api/lib/opensearch/api/actions/indices/get.rb index 02e3c535b..9a01a6b1e 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/get.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/get.rb @@ -31,7 +31,6 @@ module Actions # Returns information about one or more indices. # # @option arguments [List] :index A comma-separated list of index names - # @option arguments [Boolean] :include_type_name Whether to add the type name to the response (default: false) # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) # @option arguments [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false) # @option arguments [Boolean] :allow_no_indices Ignore if a wildcard expression resolves to no concrete indices (default: false) @@ -63,7 +62,6 @@ def get(arguments = {}) # # @since 6.2.0 ParamsRegistry.register(:get, [ - :include_type_name, :local, :ignore_unavailable, :allow_no_indices, diff --git a/opensearch-api/lib/opensearch/api/actions/indices/get_field_mapping.rb b/opensearch-api/lib/opensearch/api/actions/indices/get_field_mapping.rb index 2cc90fd8f..9653f2a0c 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/get_field_mapping.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/get_field_mapping.rb @@ -32,7 +32,6 @@ module Actions # # @option arguments [List] :fields A comma-separated list of fields # @option arguments [List] :index A comma-separated list of index names - # @option arguments [Boolean] :include_type_name Whether a type should be returned in the body of the mappings. # @option arguments [Boolean] :include_defaults Whether the default mapping values should be returned as well # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) # @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) @@ -72,7 +71,6 @@ def get_field_mapping(arguments = {}) # # @since 6.2.0 ParamsRegistry.register(:get_field_mapping, [ - :include_type_name, :include_defaults, :ignore_unavailable, :allow_no_indices, diff --git a/opensearch-api/lib/opensearch/api/actions/indices/get_mapping.rb b/opensearch-api/lib/opensearch/api/actions/indices/get_mapping.rb index 3ed0a0ae5..f39f43cd6 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/get_mapping.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/get_mapping.rb @@ -31,7 +31,6 @@ module Actions # Returns mappings for one or more indices. # # @option arguments [List] :index A comma-separated list of index names - # @option arguments [Boolean] :include_type_name Whether to add the type name to the response (default: false) # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) # @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) # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) @@ -68,7 +67,6 @@ def get_mapping(arguments = {}) # # @since 6.2.0 ParamsRegistry.register(:get_mapping, [ - :include_type_name, :ignore_unavailable, :allow_no_indices, :expand_wildcards, diff --git a/opensearch-api/lib/opensearch/api/actions/indices/get_template.rb b/opensearch-api/lib/opensearch/api/actions/indices/get_template.rb index f021638d7..1927abc8b 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/get_template.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/get_template.rb @@ -31,7 +31,6 @@ module Actions # Returns an index template. # # @option arguments [List] :name The comma separated names of the index templates - # @option arguments [Boolean] :include_type_name Whether a type should be returned in the body of the mappings. # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) @@ -61,7 +60,6 @@ def get_template(arguments = {}) # # @since 6.2.0 ParamsRegistry.register(:get_template, [ - :include_type_name, :flat_settings, :master_timeout, :local diff --git a/opensearch-api/lib/opensearch/api/actions/indices/put_mapping.rb b/opensearch-api/lib/opensearch/api/actions/indices/put_mapping.rb index 26c08f078..23945bbd5 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/put_mapping.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/put_mapping.rb @@ -31,7 +31,6 @@ module Actions # Updates the index mappings. # # @option arguments [List] :index A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - # @option arguments [Boolean] :include_type_name Whether a type should be expected in the body of the mappings. # @option arguments [Time] :timeout Explicit operation timeout # @option arguments [Time] :master_timeout Specify timeout for connection to master # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -68,7 +67,6 @@ def put_mapping(arguments = {}) # # @since 6.2.0 ParamsRegistry.register(:put_mapping, [ - :include_type_name, :timeout, :master_timeout, :ignore_unavailable, diff --git a/opensearch-api/lib/opensearch/api/actions/indices/put_template.rb b/opensearch-api/lib/opensearch/api/actions/indices/put_template.rb index 59f613150..f76359d85 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/put_template.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/put_template.rb @@ -31,7 +31,6 @@ module Actions # Creates or updates an index template. # # @option arguments [String] :name The name of the template - # @option arguments [Boolean] :include_type_name Whether a type should be returned in the body of the mappings. # @option arguments [Number] :order The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) # @option arguments [Boolean] :create Whether the index template should only be added if new or can also replace an existing one # @option arguments [Time] :master_timeout Specify timeout for connection to master @@ -61,7 +60,6 @@ def put_template(arguments = {}) # # @since 6.2.0 ParamsRegistry.register(:put_template, [ - :include_type_name, :order, :create, :master_timeout diff --git a/opensearch-api/lib/opensearch/api/actions/indices/rollover.rb b/opensearch-api/lib/opensearch/api/actions/indices/rollover.rb index f33b3d554..49c6b2b30 100644 --- a/opensearch-api/lib/opensearch/api/actions/indices/rollover.rb +++ b/opensearch-api/lib/opensearch/api/actions/indices/rollover.rb @@ -33,7 +33,6 @@ module Actions # # @option arguments [String] :alias The name of the alias to rollover # @option arguments [String] :new_index The name of the rollover index - # @option arguments [Boolean] :include_type_name Whether a type should be included in the body of the mappings. # @option arguments [Time] :timeout Explicit operation timeout # @option arguments [Boolean] :dry_run If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false # @option arguments [Time] :master_timeout Specify timeout for connection to master @@ -69,7 +68,6 @@ def rollover(arguments = {}) # # @since 6.2.0 ParamsRegistry.register(:rollover, [ - :include_type_name, :timeout, :dry_run, :master_timeout, From 1e5a38cbbde9c3bbea8e14c1cc77d7b4a940515c Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Tue, 26 Apr 2022 18:59:09 +0000 Subject: [PATCH 4/6] Renaming workflow file for unreleased testing Signed-off-by: Vacha Shah --- .../workflows/{main copy.yml => test-unreleased.yml} | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename .github/workflows/{main copy.yml => test-unreleased.yml} (88%) diff --git a/.github/workflows/main copy.yml b/.github/workflows/test-unreleased.yml similarity index 88% rename from .github/workflows/main copy.yml rename to .github/workflows/test-unreleased.yml index 9641ad1e4..390c8df40 100644 --- a/.github/workflows/main copy.yml +++ b/.github/workflows/test-unreleased.yml @@ -8,12 +8,13 @@ on: branches: - "main" -env: - OPENSEARCH_VERSION: '2.0' - jobs: test: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + opensearch_ref: ['1.x', '2.x', '2.0', 'main'] steps: - uses: ruby/setup-ruby@v1 with: @@ -22,8 +23,8 @@ jobs: - name: Checkout OpenSearch uses: actions/checkout@v2 with: - repository: opensearch-project/opensearch - ref: ${{ env.OPENSEARCH_VERSION }} + repository: opensearch-project/OpenSearch + ref: ${{ matrix.opensearch_ref }} path: opensearch - name: Assemble OpenSearch From 1e1867af5058e101112600fd3063556e9e30c605 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Tue, 26 Apr 2022 20:48:34 +0000 Subject: [PATCH 5/6] Adding upgrade documentation Signed-off-by: Vacha Shah --- COMPATIBILITY.md | 7 ++++++- opensearch/README.md | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 17a0bbc71..f998c7eac 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -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 | \ No newline at end of file +| 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. \ No newline at end of file diff --git a/opensearch/README.md b/opensearch/README.md index 961156bf4..b783ae240 100644 --- a/opensearch/README.md +++ b/opensearch/README.md @@ -20,6 +20,8 @@ The OpenSearch client for Ruby is compatible with Ruby 1.9 and higher. The client's API is compatible with OpenSearch's API versions from 1.0.0 till current. +See [COMPATIBILITY](../COMPATIBILITY.md) for more details. + ## Installation Install the package from [Rubygems](https://rubygems.org): From d988c338215f09fef1ba2df63bf3848cdc371f5e Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Wed, 27 Apr 2022 18:59:49 +0000 Subject: [PATCH 6/6] Separating the opensearch_ref linewise Signed-off-by: Vacha Shah --- .github/workflows/test-unreleased.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-unreleased.yml b/.github/workflows/test-unreleased.yml index 390c8df40..98ca160d2 100644 --- a/.github/workflows/test-unreleased.yml +++ b/.github/workflows/test-unreleased.yml @@ -14,7 +14,11 @@ jobs: strategy: fail-fast: false matrix: - opensearch_ref: ['1.x', '2.x', '2.0', 'main'] + entry: + - { opensearch_ref: '1.x' } + - { opensearch_ref: '2.x' } + - { opensearch_ref: '2.0' } + - { opensearch_ref: 'main' } steps: - uses: ruby/setup-ruby@v1 with: @@ -24,7 +28,7 @@ jobs: uses: actions/checkout@v2 with: repository: opensearch-project/OpenSearch - ref: ${{ matrix.opensearch_ref }} + ref: ${{ matrix.entry.opensearch_ref }} path: opensearch - name: Assemble OpenSearch