[DRE-commits] [ruby-elasticsearch] 01/02: Imported Upstream version 5.0.1
Macártur Carvalho
macartur-guest at moszumanska.debian.org
Wed Jan 25 11:26:00 UTC 2017
This is an automated email from the git hooks/post-receive script.
macartur-guest pushed a commit to branch master
in repository ruby-elasticsearch.
commit b59d44d26a306e1392ed46ee74ab65f2026cd46b
Author: Macartur Sousa <macartur.sc at gmail.com>
Date: Wed Jan 25 09:15:02 2017 -0200
Imported Upstream version 5.0.1
---
CHANGELOG.md | 13 +++
README.md | 21 ++--
Rakefile | 2 +-
elasticsearch-api/README.md | 19 ++--
elasticsearch-api/elasticsearch-api.gemspec | 2 +-
elasticsearch-api/lib/elasticsearch/api.rb | 1 +
.../lib/elasticsearch/api/actions/bulk.rb | 38 ++++---
.../lib/elasticsearch/api/actions/cat/aliases.rb | 11 +-
.../elasticsearch/api/actions/cat/allocation.rb | 7 +-
.../lib/elasticsearch/api/actions/cat/count.rb | 7 +-
.../lib/elasticsearch/api/actions/cat/fielddata.rb | 5 +-
.../lib/elasticsearch/api/actions/cat/health.rb | 7 +-
.../lib/elasticsearch/api/actions/cat/indices.rb | 14 ++-
.../lib/elasticsearch/api/actions/cat/master.rb | 7 +-
.../lib/elasticsearch/api/actions/cat/nodeattrs.rb | 10 +-
.../lib/elasticsearch/api/actions/cat/nodes.rb | 9 +-
.../elasticsearch/api/actions/cat/pending_tasks.rb | 7 +-
.../lib/elasticsearch/api/actions/cat/plugins.rb | 10 +-
.../lib/elasticsearch/api/actions/cat/recovery.rb | 7 +-
.../elasticsearch/api/actions/cat/repositories.rb | 7 +-
.../lib/elasticsearch/api/actions/cat/segments.rb | 11 +-
.../lib/elasticsearch/api/actions/cat/shards.rb | 7 +-
.../lib/elasticsearch/api/actions/cat/snapshots.rb | 9 +-
.../lib/elasticsearch/api/actions/cat/tasks.rb | 10 +-
.../api/actions/cat/{nodeattrs.rb => templates.rb} | 20 ++--
.../elasticsearch/api/actions/cat/thread_pool.rb | 10 +-
.../api/actions/cluster/allocation_explain.rb | 11 +-
.../api/actions/cluster/get_settings.rb | 3 -
.../elasticsearch/api/actions/cluster/health.rb | 8 +-
.../elasticsearch/api/actions/cluster/reroute.rb | 3 -
.../elasticsearch/api/actions/delete_by_query.rb | 90 ++++++++++-----
.../lib/elasticsearch/api/actions/explain.rb | 4 +-
.../lib/elasticsearch/api/actions/get.rb | 4 +-
.../lib/elasticsearch/api/actions/index.rb | 5 +-
.../elasticsearch/api/actions/indices/create.rb | 4 +-
.../lib/elasticsearch/api/actions/indices/get.rb | 3 -
.../api/actions/indices/get_settings.rb | 3 -
.../api/actions/indices/put_settings.rb | 3 -
.../elasticsearch/api/actions/indices/rollover.rb | 41 +++++++
.../elasticsearch/api/actions/indices/shrink.rb | 45 ++++++++
.../lib/elasticsearch/api/actions/indices/stats.rb | 9 +-
.../api/actions/indices/validate_query.rb | 6 +-
.../api/actions/ingest/delete_pipeline.rb | 6 +-
.../api/actions/ingest/get_pipeline.rb | 9 +-
.../api/actions/ingest/put_pipeline.rb | 6 +-
.../elasticsearch/api/actions/ingest/simulate.rb | 9 +-
.../lib/elasticsearch/api/actions/mget.rb | 4 +-
.../lib/elasticsearch/api/actions/nodes/info.rb | 3 +-
.../lib/elasticsearch/api/actions/nodes/stats.rb | 2 +
.../lib/elasticsearch/api/actions/ping.rb | 2 +-
.../lib/elasticsearch/api/actions/scroll.rb | 12 +-
.../lib/elasticsearch/api/actions/search.rb | 7 ++
.../lib/elasticsearch/api/actions/snapshot/get.rb | 2 +
.../elasticsearch/api/actions/snapshot/status.rb | 2 +
.../lib/elasticsearch/api/actions/tasks/list.rb | 3 -
.../lib/elasticsearch/api/actions/update.rb | 7 ++
.../elasticsearch/api/actions/update_by_query.rb | 3 -
elasticsearch-api/lib/elasticsearch/api/utils.rb | 12 +-
elasticsearch-api/lib/elasticsearch/api/version.rb | 2 +-
.../test/integration/yaml_test_runner.rb | 107 +++++++++++------
elasticsearch-api/test/unit/cat/templates_test.rb | 26 +++++
.../test/unit/delete_by_query_test.rb | 8 +-
.../test/unit/indices/rollover_test.rb | 38 +++++++
elasticsearch-api/test/unit/indices/shrink_test.rb | 33 ++++++
.../test/unit/ingest/get_pipeline_test.rb | 6 -
elasticsearch-api/utils/thor/generate_source.rb | 12 ++
.../utils/thor/templates/ruby/method.erb | 14 +--
.../utils/thor/templates/ruby/test.erb | 6 +-
elasticsearch-dsl/Gemfile | 8 +-
elasticsearch-dsl/Rakefile | 6 +-
.../lib/elasticsearch/dsl/search/queries/bool.rb | 12 +-
.../lib/elasticsearch/dsl/search/queries/exists.rb | 44 +++++++
.../dsl/search/queries/more_like_this.rb | 16 ++-
.../lib/elasticsearch/dsl/search/queries/nested.rb | 1 +
.../test/integration/search_query_test.rb | 16 +++
elasticsearch-dsl/test/test_helper.rb | 1 +
elasticsearch-dsl/test/unit/queries/bool_test.rb | 43 ++++++-
elasticsearch-dsl/test/unit/queries/exists_test.rb | 36 ++++++
elasticsearch-dsl/test/unit/queries/nested_test.rb | 4 +-
elasticsearch-extensions/Gemfile | 10 +-
elasticsearch-extensions/README.md | 8 +-
.../elasticsearch-extensions.gemspec | 4 +-
.../lib/elasticsearch/extensions/reindex.rb | 41 ++++---
.../lib/elasticsearch/extensions/test/cluster.rb | 74 ++++++++----
.../test/reindex/integration/reindex_test.rb | 45 +++++++-
.../test/reindex/unit/reindex_test.rb | 30 ++---
.../test/test/cluster/integration/cluster_test.rb | 5 +
.../test/test/cluster/unit/cluster_test.rb | 39 ++++++-
elasticsearch-transport/Gemfile | 2 +-
elasticsearch-transport/README.md | 2 +-
.../elasticsearch-transport.gemspec | 2 +-
.../lib/elasticsearch/transport/transport/base.rb | 12 +-
.../elasticsearch/transport/transport/http/curb.rb | 6 +-
.../transport/transport/http/faraday.rb | 5 +-
.../elasticsearch/transport/transport/sniffer.rb | 20 ++--
.../lib/elasticsearch/transport/version.rb | 2 +-
.../test/integration/client_test.rb | 43 ++++---
elasticsearch-transport/test/unit/sniffer_test.rb | 126 +++++++++------------
.../test/unit/transport_base_test.rb | 15 +++
.../test/unit/transport_curb_test.rb | 2 +-
.../test/unit/transport_faraday_test.rb | 6 +-
elasticsearch/Gemfile | 6 +-
elasticsearch/README.md | 15 ++-
elasticsearch/elasticsearch.gemspec | 6 +-
elasticsearch/lib/elasticsearch/version.rb | 2 +-
105 files changed, 1063 insertions(+), 506 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2691a2..3da193a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,20 @@
+## 5.0.0
+
+### API
+
+* Updated the parameters for Elasticsearch 5.x APIs
+* Added Elasticsearch 5.x APIs
+
## 2.0.0
* Added deprecation notices to API methods and parameters not supported on Elasticsearch 2.x
+## 1.1.0
+
+### API
+
+* Added deprecation notices to API methods and arguments not supported on Elasticsearch 1.x
+
## DSL:0.1.4
* Added correct implementation of `Sort#empty?`
diff --git a/README.md b/README.md
index 3203dbc..4c18ae1 100644
--- a/README.md
+++ b/README.md
@@ -11,14 +11,19 @@ see the <https://github.com/elasticsearch/elasticsearch-rails> project.
## Compatibility
-The libraries are compatible with Ruby 1.8.7 and higher.
-
-The library is compatible with Elasticsearch 0.90, 1.x and 2.x -- you have to install and use a matching version, though.
-
-The 1.x versions and the master branch are compatible with Elasticsearch 1.x and 2.x APIs.
-
-To use the **Elasticsearch 0.90** API, install the **0.4.x** gem version or use the corresponding
-[`0.4`](https://github.com/elasticsearch/elasticsearch-ruby/tree/0.4) branch.
+The Elasticsearch client is compatible with Ruby 1.8.7 and higher.
+Other libraries in this repository might require a more recent Ruby version.
+
+The client's API is compatible with Elasticsearch's API versions from 0.90 till current,
+just use a release matching major version of Elasticsearch.
+
+| Ruby | | Elasticsearch |
+|:-------------:|:-:| :-----------: |
+| 0.90 | → | 0.90 |
+| 1.x | → | 1.x |
+| 2.x | → | 2.x |
+| 5.x | → | 5.x |
+| master | → | master |
## Installation
diff --git a/Rakefile b/Rakefile
index ce4007e..f1b7b68 100644
--- a/Rakefile
+++ b/Rakefile
@@ -23,7 +23,7 @@ end
desc "Setup the project"
task :setup do
- unless File.exists?('./tmp/elasticsearch')
+ unless File.exist?('./tmp/elasticsearch')
sh "git clone https://github.com/elasticsearch/elasticsearch.git tmp/elasticsearch"
end
end
diff --git a/elasticsearch-api/README.md b/elasticsearch-api/README.md
index a7df8c0..db0afd0 100644
--- a/elasticsearch-api/README.md
+++ b/elasticsearch-api/README.md
@@ -9,17 +9,20 @@ The `elasticsearch-api` library provides a Ruby implementation of
the [Elasticsearch](http://elasticsearch.org) REST API.
It does not provide an Elasticsearch client; see the
-[`elasticsearch-transport`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-transport)
-library.
+[`elasticsearch-transport`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-transport) library.
-The library is compatible with Ruby 1.8.7 or higher.
+The library is compatible with Ruby 1.8.7 and higher.
-The library is compatible with Elasticsearch 0.90, 1.x and 2.x -- you have to install and use a matching version, though.
+It is compatible with Elasticsearch's API versions from 0.90 till current,
+just use a release matching major version of Elasticsearch.
-The 1.x versions and the master branch are compatible with Elasticsearch 1.x and 2.x APIs.
-
-To use the **Elasticsearch 0.90** API, install the **0.4.x** gem version or use the corresponding
-[`0.4`](https://github.com/elasticsearch/elasticsearch-ruby/tree/0.4) branch.
+| Ruby | | Elasticsearch |
+|:-------------:|:-:| :-----------: |
+| 0.90 | → | 0.90 |
+| 1.x | → | 1.x |
+| 2.x | → | 2.x |
+| 5.x | → | 5.x |
+| master | → | master |
## Installation
diff --git a/elasticsearch-api/elasticsearch-api.gemspec b/elasticsearch-api/elasticsearch-api.gemspec
index d97b1b1..220be0c 100644
--- a/elasticsearch-api/elasticsearch-api.gemspec
+++ b/elasticsearch-api/elasticsearch-api.gemspec
@@ -53,7 +53,7 @@ Gem::Specification.new do |s|
# Prevent unit test failures on Ruby 1.8
if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
s.add_development_dependency "test-unit", '~> 2'
- s.add_development_dependency "json"
+ s.add_development_dependency "json", '~> 1.8'
end
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
diff --git a/elasticsearch-api/lib/elasticsearch/api.rb b/elasticsearch-api/lib/elasticsearch/api.rb
index d9d96e2..81718c9 100644
--- a/elasticsearch-api/lib/elasticsearch/api.rb
+++ b/elasticsearch-api/lib/elasticsearch/api.rb
@@ -22,6 +22,7 @@ module Elasticsearch
]
COMMON_QUERY_PARAMS = [
+ :ignore, # Client specific parameters
:format, # Search, Cat, ...
:pretty, # Pretty-print the response
:human, # Return numeric values in human readable format
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb b/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb
index 000695a..d88c2db 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb
@@ -45,21 +45,23 @@ module Elasticsearch
#
# ]
#
- # @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 [Array<Hash>] :body An array of operations to perform, each operation is a Hash
- # @option arguments [String] :consistency Explicit write consistency setting for the operation
- # (options: one, quorum, all)
- # @option arguments [Boolean] :refresh Refresh the index after performing the operation
- # @option arguments [String] :replication Explicitly set the replication type (options: sync, async)
- # @option arguments [Time] :timeout Explicit operation timeout
- # @option arguments [String] :fields Default comma-separated list of fields to return
- # in the response for updates
- # @options arguments [String] :pipeline The pipeline ID to use for preprocessing incoming documents
+ # @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 [Hash] :body The operation definition and data (action-data pairs), separated by newlines (*Required*)
+ # @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 effected 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
+ # @option arguments [Time] :timeout Explicit operation timeout
+ # @option arguments [String] :type Default document type for items which don't provide one
+ # @option arguments [List] :fields Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request
+ # @option arguments [List] :_source True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request
+ # @option arguments [List] :_source_exclude Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
+ # @option arguments [List] :_source_include Default list of fields to extract and return from the _source field, can be overridden on each sub-request
+ # @option arguments [String] :pipeline The pipeline ID to preprocess incoming documents with
#
# @return [Hash] Deserialized Elasticsearch response
#
- # @see http://elasticsearch.org/guide/reference/api/bulk/
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
#
def bulk(arguments={})
arguments = arguments.clone
@@ -67,17 +69,17 @@ module Elasticsearch
type = arguments.delete(:type)
valid_params = [
- :consistency,
+ :wait_for_active_shards,
:refresh,
- :replication,
- :type,
+ :routing,
:timeout,
+ :type,
:fields,
+ :_source,
+ :_source_exclude,
+ :_source_include,
:pipeline ]
- unsupported_params = [ :fields, :pipeline ]
- Utils.__report_unsupported_parameters(arguments, unsupported_params)
-
method = HTTP_POST
path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(type), '_bulk'
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/aliases.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/aliases.rb
index 6532ecd..669129f 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/aliases.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/aliases.rb
@@ -25,6 +25,10 @@ module Elasticsearch
#
# puts client.cat.aliases h: 'a,i'
#
+ # @example Return the output sorted by the alias name
+ #
+ # puts client.cat.aliases s: 'alias'
+ #
# @example Return the information as Ruby objects
#
# client.cat.aliases format: 'json'
@@ -32,6 +36,7 @@ module Elasticsearch
# @option arguments [List] :name A comma-separated list of alias names to return
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -46,10 +51,8 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
name = arguments.delete(:name)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/allocation.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/allocation.rb
index e4499dc..8961126 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/allocation.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/allocation.rb
@@ -33,6 +33,7 @@ module Elasticsearch
# @option arguments [String] :bytes The unit in which to display byte values (options: b, k, m, g)
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -48,10 +49,8 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
node_id = arguments.delete(:node_id)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb
index ece0175..c616c3e 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb
@@ -28,6 +28,7 @@ module Elasticsearch
# @option arguments [List] :index A comma-separated list of index names to limit the returned information
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -42,10 +43,8 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
index = arguments.delete(:index)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/fielddata.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/fielddata.rb
index 67d1120..b32bc63 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/fielddata.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/fielddata.rb
@@ -21,6 +21,7 @@ module Elasticsearch
# @option arguments [List] :h Comma-separated list of column names to display
# @option arguments [Boolean] :help Return help information
# @option arguments [Boolean] :v Verbose mode. Display column headers
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
#
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-fielddata.html
#
@@ -32,11 +33,9 @@ module Elasticsearch
:h,
:help,
:v,
+ :s,
:fields ]
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
fields = arguments.delete(:fields)
method = HTTP_GET
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/health.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/health.rb
index f3a7ef4..2a06516 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/health.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/health.rb
@@ -20,6 +20,7 @@ module Elasticsearch
# @option arguments [Boolean] :ts Whether to display timestamp information
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -35,10 +36,8 @@ module Elasticsearch
:h,
:help,
:ts,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
method = HTTP_GET
path = "_cat/health"
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/indices.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/indices.rb
index 72245f4..6226664 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/indices.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/indices.rb
@@ -40,6 +40,9 @@ module Elasticsearch
# @option arguments [Boolean] :pri Limit the returned information on primary shards only (default: false)
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
+ # @option arguments [String] :health A health status ("green", "yellow", or "red" to filter only indices
+ # matching the specified health status (options: green, yellow, red)
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -51,15 +54,14 @@ module Elasticsearch
def indices(arguments={})
valid_params = [
:bytes,
- :local,
- :master_timeout,
:h,
+ :health,
:help,
+ :local,
+ :master_timeout,
:pri,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
index = arguments.delete(:index)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/master.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/master.rb
index 487e471..5b7e4cf 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/master.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/master.rb
@@ -19,6 +19,7 @@ module Elasticsearch
#
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -33,10 +34,8 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
method = HTTP_GET
path = "_cat/master"
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb
index 5fafcc4..8336560 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb
@@ -10,6 +10,7 @@ module Elasticsearch
# @option arguments [List] :h Comma-separated list of column names to display
# @option arguments [Boolean] :help Return help information
# @option arguments [Boolean] :v Verbose mode. Display column headers
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
#
# @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html
#
@@ -19,12 +20,9 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
- method = HTTP_GET
+ :v,
+ :s ]
+ method = 'GET'
path = "_cat/nodeattrs"
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodes.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodes.rb
index 658bcb3..e0b9ab8 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodes.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodes.rb
@@ -25,8 +25,10 @@ module Elasticsearch
#
# client.cat.nodes format: 'json'
#
+ # @option arguments [Boolean] :full_id Return the full node ID instead of the shortened version (default: false)
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -37,14 +39,13 @@ module Elasticsearch
#
def nodes(arguments={})
valid_params = [
+ :full_id,
:local,
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
method = HTTP_GET
path = "_cat/nodes"
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/pending_tasks.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/pending_tasks.rb
index db2c1f0..8acc177 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/pending_tasks.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/pending_tasks.rb
@@ -19,6 +19,7 @@ module Elasticsearch
#
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -33,10 +34,8 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
method = HTTP_GET
path = "_cat/pending_tasks"
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/plugins.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/plugins.rb
index 343516e..2bc1e1d 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/plugins.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/plugins.rb
@@ -9,6 +9,7 @@ module Elasticsearch
# (default: false)
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
# @option arguments [List] :h Comma-separated list of column names to display
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [Boolean] :help Return help information
# @option arguments [Boolean] :v Verbose mode. Display column headers
#
@@ -20,12 +21,9 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
- method = HTTP_GET
+ :v,
+ :s ]
+ method = 'GET'
path = "_cat/plugins"
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb
index 3ad0e59..873ff85 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb
@@ -37,6 +37,7 @@ module Elasticsearch
# @option arguments [String] :bytes The unit in which to display byte values (options: b, k, m, g)
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -52,10 +53,8 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
index = arguments.delete(:index)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/repositories.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/repositories.rb
index 81a8d75..7b44a6e 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/repositories.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/repositories.rb
@@ -17,6 +17,7 @@ module Elasticsearch
# @option arguments [List] :h Comma-separated list of column names to display
# @option arguments [Boolean] :help Return help information
# @option arguments [Boolean] :v Verbose mode. Display column headers
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-repositories.html
#
@@ -25,10 +26,8 @@ module Elasticsearch
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
method = HTTP_GET
path = "_cat/repositories"
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb
index abe1c90..78c94d5 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb
@@ -14,20 +14,19 @@ module Elasticsearch
# @option arguments [List] :h Comma-separated list of column names to display
# @option arguments [Boolean] :help Return help information
# @option arguments [Boolean] :v Verbose mode. Display column headers
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
#
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-segments.html
#
def segments(arguments={})
valid_params = [
:bytes,
+ :index,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
- method = HTTP_GET
+ :v,
+ :s ]
+ method = 'GET'
path = "_cat/segments"
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/shards.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/shards.rb
index 61a5c5d..fe1134d 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/shards.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/shards.rb
@@ -41,6 +41,7 @@ module Elasticsearch
# @option arguments [String] :bytes The unit in which to display byte values (options: b, k, m, g)
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -56,10 +57,8 @@ module Elasticsearch
:bytes,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
index = arguments.delete(:index)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb
index f470ddd..b88d720 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb
@@ -17,20 +17,19 @@ module Elasticsearch
# @option arguments [List] :h Comma-separated list of column names to display
# @option arguments [Boolean] :help Return help information
# @option arguments [Boolean] :v Verbose mode. Display column headers
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-snapshots.html
#
def snapshots(arguments={})
- raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
+ raise ArgumentError, "Required argument 'repository' missing" if !arguments[:repository] && !arguments[:help]
valid_params = [
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
repository = arguments.delete(:repository)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/tasks.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/tasks.rb
index c9f2ce4..874d890 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/tasks.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/tasks.rb
@@ -14,12 +14,11 @@ module Elasticsearch
# @option arguments [List] :h Comma-separated list of column names to display
# @option arguments [Boolean] :help Return help information
# @option arguments [Boolean] :v Verbose mode. Display column headers
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
#
# @see http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html
#
def tasks(arguments={})
- Utils.__report_unsupported_method(__method__)
-
valid_params = [
:format,
:node_id,
@@ -29,10 +28,9 @@ module Elasticsearch
:parent_task,
:h,
:help,
- :v ]
-
- method = HTTP_GET
-
+ :v,
+ :s ]
+ method = 'GET'
path = "_cat/tasks"
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/templates.rb
similarity index 64%
copy from elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb
copy to elasticsearch-api/lib/elasticsearch/api/actions/cat/templates.rb
index 5fafcc4..60751bb 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/templates.rb
@@ -3,29 +3,31 @@ module Elasticsearch
module Cat
module Actions
- # Display custom node attributes
+ # Returns information about existing templates
#
+ # @option arguments [String] :name A pattern that returned template names must match
+ # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
# @option arguments [List] :h Comma-separated list of column names to display
# @option arguments [Boolean] :help Return help information
# @option arguments [Boolean] :v Verbose mode. Display column headers
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
#
- # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html
+ # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html
#
- def nodeattrs(arguments={})
+ def templates(arguments={})
valid_params = [
+ :name,
+ :format,
:local,
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
+ :v,
+ :s ]
method = HTTP_GET
- path = "_cat/nodeattrs"
+ path = "_cat/templates"
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/thread_pool.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/thread_pool.rb
index 5c5c5b0..df88da4 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/thread_pool.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/thread_pool.rb
@@ -25,8 +25,11 @@ module Elasticsearch
# @option arguments [Boolean] :full_id Display the complete node ID
# @option arguments [String] :size The multiplier in which to display values
# (Options: k, m, g, t, p)
+ # @option arguments [List] :thread_pool_patterns A comma-separated list of regular expressions to filter
+ # the thread pools in the output
# @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
# @option arguments [Boolean] :v Display column headers as part of the output
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
# @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
# @option arguments [Boolean] :help Return information about headers
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
@@ -40,13 +43,12 @@ module Elasticsearch
:full_id,
:size,
:local,
+ :thread_pool_patterns,
:master_timeout,
:h,
:help,
- :v ]
-
- unsupported_params = [ :format, :size ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
+ :v,
+ :s ]
method = HTTP_GET
path = "_cat/thread_pool"
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb
index 0d4ba7f..5091047 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb
@@ -7,15 +7,16 @@ module Elasticsearch
#
# @option arguments [Hash] :body The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard'
# @option arguments [Boolean] :include_yes_decisions Return 'YES' decisions in explanation (default: false)
+ # @option arguments [Boolean] :include_disk_info Return information about disk usage and shard sizes
+ # (default: false)
#
# @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html
#
def allocation_explain(arguments={})
- Utils.__report_unsupported_method(__method__)
-
- valid_params = [ :include_yes_decisions ]
-
- method = HTTP_GET
+ valid_params = [
+ :include_yes_decisions,
+ :include_disk_info ]
+ method = 'GET'
path = "_cluster/allocation/explain"
params = Utils.__validate_and_extract_params arguments, valid_params
body = arguments[:body]
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_settings.rb
index 3aa59da..115332e 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_settings.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_settings.rb
@@ -21,9 +21,6 @@ module Elasticsearch
:include_defaults
]
- unsupported_params = [ :include_defaults ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
method = HTTP_GET
path = "_cluster/settings"
params = Utils.__validate_and_extract_params arguments, valid_params
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/health.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/health.rb
index b681f33..38d7f22 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/health.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/health.rb
@@ -24,8 +24,12 @@ module Elasticsearch
# @option arguments [Number] :wait_for_nodes Wait until the specified number of nodes is available
# @option arguments [Number] :wait_for_relocating_shards Wait until the specified number of relocating
# shards is finished
+ # @option arguments [Boolean] :wait_for_no_relocating_shards Whether to wait until there are no relocating
+ # shards in the cluster
# @option arguments [String] :wait_for_status Wait until cluster is in a specific state
# (options: green, yellow, red)
+ # @option arguments [List] :wait_for_events Wait until all currently queued events with the given priorty
+ # are processed (immediate, urgent, high, normal, low, languid)
#
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-health/
#
@@ -41,7 +45,9 @@ module Elasticsearch
:wait_for_active_shards,
:wait_for_nodes,
:wait_for_relocating_shards,
- :wait_for_status ]
+ :wait_for_no_relocating_shards,
+ :wait_for_status,
+ :wait_for_events ]
method = HTTP_GET
path = Utils.__pathify "_cluster/health", Utils.__listify(index)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb
index 77a9893..de73709 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb
@@ -34,9 +34,6 @@ module Elasticsearch
def reroute(arguments={})
valid_params = [ :dry_run, :explain, :metric, :master_timeout, :retry_failed, :timeout ]
- unsupported_params = [ :retry_failed ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
method = HTTP_POST
path = "_cluster/reroute"
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb
index cc61a30..32b85ae 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb
@@ -15,57 +15,85 @@ module Elasticsearch
#
# client.delete_by_query index: 'myindex', body: { query: { term: { published: false } } }
#
- # @option arguments [List] :index A comma-separated list of indices to restrict the operation;
- # use `_all`to perform the operation on all indices (*Required*)
- # @option arguments [List] :type A comma-separated list of types to restrict the operation
- # @option arguments [Hash] :body A query to restrict the operation
+ # @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 [Hash] :body The search definition using the Query DSL (*Required*)
# @option arguments [String] :analyzer The analyzer to use for the query string
- # @option arguments [String] :consistency Specific write consistency setting for the operation
- # (options: one, quorum, all)
- # @option arguments [String] :default_operator The default operator for query string query (AND or OR)
- # (options: AND, OR)
+ # @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)
# @option arguments [String] :df The field to use as default where no field prefix is given in the query string
- # @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)
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
- # `missing` ones (options: none, missing) @until 1.0
- # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
- # unavailable (missing, closed, etc)
- # @option arguments [String] :replication Specific replication type (options: sync, async)
+ # @option arguments [Number] :from Starting offset (default: 0)
+ # @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] :conflicts What to do when the delete-by-query hits version conflicts? (options: abort, proceed)
+ # @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 [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
+ # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
# @option arguments [String] :q Query in the Lucene query string syntax
- # @option arguments [String] :routing Specific routing value
- # @option arguments [String] :source The URL-encoded query definition (instead of using the request body)
- # @option arguments [Time] :timeout Explicit operation timeout
+ # @option arguments [List] :routing A comma-separated list of specific routing values
+ # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
+ # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch)
+ # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
+ # @option arguments [Number] :size Number of hits to return (default: 10)
+ # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
+ # @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_exclude A list of fields to exclude from the returned _source field
+ # @option arguments [List] :_source_include A list of fields to extract and return from the _source field
+ # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
+ # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
+ # @option arguments [Boolean] :version Specify whether to return document version as part of a hit
+ # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting
+ # @option arguments [Boolean] :refresh Should the effected indexes be refreshed?
+ # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable.
+ # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete by query 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 [Number] :scroll_size Size on the scroll request powering the update_by_query
+ # @option arguments [Boolean] :wait_for_completion Should the request should block until the delete-by-query is complete.
+ # @option arguments [Number] :requests_per_second The throttle for this request in sub-requests per second. -1 means no throttle.
+ # @option arguments [Integer] :slices The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
#
- # @see http://www.elasticsearch.org/guide/reference/api/delete-by-query/
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html
#
def delete_by_query(arguments={})
- Utils.__report_unsupported_method(__method__)
-
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
valid_params = [
:analyzer,
- :consistency,
+ :analyze_wildcard,
:default_operator,
:df,
- :ignore_indices,
+ :from,
:ignore_unavailable,
:allow_no_indices,
+ :conflicts,
:expand_wildcards,
- :replication,
+ :lenient,
+ :preference,
:q,
:routing,
- :source,
- :timeout ]
+ :scroll,
+ :search_type,
+ :search_timeout,
+ :size,
+ :sort,
+ :_source,
+ :_source_exclude,
+ :_source_include,
+ :terminate_after,
+ :stats,
+ :version,
+ :request_cache,
+ :refresh,
+ :timeout,
+ :wait_for_active_shards,
+ :scroll_size,
+ :wait_for_completion,
+ :requests_per_second,
+ :slices ]
- method = HTTP_DELETE
+ method = HTTP_POST
path = Utils.__pathify Utils.__listify(arguments[:index]),
Utils.__listify(arguments[:type]),
- '/_query'
+ '/_delete_by_query'
params = Utils.__validate_and_extract_params arguments, valid_params
body = arguments[:body]
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb b/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb
index ee1e8f3..d8ccd61 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb
@@ -39,6 +39,7 @@ module Elasticsearch
# or a list of fields to return
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
+ # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
#
# @see http://elasticsearch.org/guide/reference/api/explain/
#
@@ -62,7 +63,8 @@ module Elasticsearch
:source,
:_source,
:_source_include,
- :_source_exclude ]
+ :_source_exclude,
+ :stored_fields ]
method = HTTP_GET
path = Utils.__pathify Utils.__escape(arguments[:index]),
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/get.rb
index 368ce63..b2fc29b 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/get.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/get.rb
@@ -29,6 +29,7 @@ module Elasticsearch
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
# @option arguments [Boolean] :_source_transform Retransform the source before returning it
+ # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
#
# @see http://elasticsearch.org/guide/reference/api/get/
#
@@ -49,7 +50,8 @@ module Elasticsearch
:_source,
:_source_include,
:_source_exclude,
- :_source_transform]
+ :_source_transform,
+ :stored_fields ]
method = HTTP_GET
path = Utils.__pathify Utils.__escape(arguments[:index]),
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index.rb
index d15bc9d..1c6c883 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/index.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/index.rb
@@ -7,7 +7,7 @@ module Elasticsearch
# The `index` API will either _create_ a new document, or _update_ an existing one, when a document `:id`
# is passed. When creating a document, an ID will be auto-generated, when it's not passed as an argument.
#
- # You can specifically enforce the _create_ operation by settint the `op_type` argument to `create`, or
+ # You can specifically enforce the _create_ operation by setting the `op_type` argument to `create`, or
# by using the {Actions#create} method.
#
# Optimistic concurrency control is performed, when the `version` argument is specified. By default,
@@ -89,9 +89,6 @@ module Elasticsearch
:version,
:version_type ]
- unsupported_params = [ :pipeline ]
- Utils.__report_unsupported_parameters(arguments, unsupported_params)
-
method = arguments[:id] ? HTTP_PUT : HTTP_POST
path = Utils.__pathify Utils.__escape(arguments[:index]),
Utils.__escape(arguments[:type]),
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb
index fc75cd3..6df8484 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb
@@ -62,6 +62,7 @@ module Elasticsearch
# @option arguments [Hash] :body Optional configuration for the index (`settings` and `mappings`)
# @option arguments [Boolean] :update_all_types Whether to update the mapping for all fields
# with the same name across all types
+ # @option arguments [Number] :wait_for_active_shards Wait until the specified number of shards is active
# @option arguments [Time] :timeout Explicit operation timeout
# @option arguments [Boolean] :master_timeout Timeout for connection to master
#
@@ -72,7 +73,8 @@ module Elasticsearch
valid_params = [
:timeout,
:master_timeout,
- :update_all_types
+ :update_all_types,
+ :wait_for_active_shards
]
method = HTTP_PUT
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get.rb
index 7803b1e..aa4f80c 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get.rb
@@ -35,9 +35,6 @@ module Elasticsearch
:human,
:include_defaults ]
- unsupported_params = [ :include_defaults ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
method = HTTP_GET
path = Utils.__pathify Utils.__listify(arguments[:index]), Utils.__listify(arguments.delete(:feature))
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_settings.rb
index 99ac5ed..e5e89fe 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_settings.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_settings.rb
@@ -53,9 +53,6 @@ module Elasticsearch
:local
]
- unsupported_params = [ :include_defaults ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
method = HTTP_GET
path = Utils.__pathify Utils.__listify(arguments[:index]),
Utils.__listify(arguments[:type]),
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb
index 5440789..d4ff80d 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb
@@ -59,9 +59,6 @@ module Elasticsearch
:flat_settings
]
- unsupported_params = [ :preserve_existing ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
method = HTTP_PUT
path = Utils.__pathify Utils.__listify(arguments[:index]), '_settings'
params = Utils.__validate_and_extract_params arguments, valid_params
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb
new file mode 100644
index 0000000..fc68abb
--- /dev/null
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb
@@ -0,0 +1,41 @@
+module Elasticsearch
+ module API
+ module Indices
+ module Actions
+
+ # The rollover index API rolls an alias over to a new index when the existing index
+ # is considered to be too large or too old
+ #
+ # @option arguments [String] :alias The name of the alias to rollover (*Required*)
+ # @option arguments [String] :new_index The name of the rollover index
+ # @option arguments [Hash] :body The conditions that needs to be met for executing rollover
+ # @option arguments [Number] :wait_for_active_shards Wait until the specified number of shards is active
+ # @option arguments [Time] :timeout Explicit operation timeout
+ # @option arguments [Time] :master_timeout Specify timeout for connection to master
+ #
+ # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html
+ #
+ def rollover(arguments={})
+ raise ArgumentError, "Required argument 'alias' missing" unless arguments[:alias]
+
+ valid_params = [
+ :wait_for_active_shards,
+ :timeout,
+ :master_timeout ]
+
+ arguments = arguments.clone
+
+ source = arguments.delete(:alias)
+ target = arguments.delete(:new_index)
+
+ method = HTTP_POST
+ path = Utils.__pathify source, '_rollover', target
+ params = Utils.__validate_and_extract_params arguments, valid_params
+ body = arguments[:body]
+
+ perform_request(method, path, params, body).body
+ end
+ end
+ end
+ end
+end
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb
new file mode 100644
index 0000000..9ce282d
--- /dev/null
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb
@@ -0,0 +1,45 @@
+module Elasticsearch
+ module API
+ module Indices
+ module Actions
+
+ # Copy an existing index into a new index with a fewer number of primary shards
+ #
+ # @option arguments [String] :index The name of the source index to shrink (*Required*)
+ # @option arguments [String] :target The name of the target index to shrink into (*Required*)
+ # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`)
+ # @option arguments [Number] :wait_for_active_shards Wait until the specified number of shards is active
+ # @option arguments [Boolean] :wait_for_no_relocating_shards Whether to wait until there are no relocating
+ # shards in the cluster
+ # @option arguments [Time] :timeout Explicit operation timeout
+ # @option arguments [Time] :master_timeout Specify timeout for connection to master
+ #
+ # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html
+ #
+ def shrink(arguments={})
+ raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
+ raise ArgumentError, "Required argument 'target' missing" unless arguments[:target]
+
+ valid_params = [
+ :wait_for_active_shards,
+ :wait_for_no_relocating_shards,
+ :timeout,
+ :master_timeout
+ ]
+
+ arguments = arguments.clone
+
+ source = arguments.delete(:index)
+ target = arguments.delete(:target)
+
+ method = HTTP_PUT
+ path = Utils.__pathify(source, '_shrink', target)
+ params = Utils.__validate_and_extract_params arguments, valid_params
+ body = arguments[:body]
+
+ perform_request(method, path, params, body).body
+ end
+ end
+ end
+ end
+end
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/stats.rb
index 1736af0..0fcc197 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/stats.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/stats.rb
@@ -71,6 +71,8 @@ module Elasticsearch
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
# are open, closed or both. (options: open, closed)
#
+ # @option arguments [Boolean] :include_segment_file_sizes Whether to report the aggregated disk usage of each one of the Lucene index files. Only applies if segment stats are requested. (default: false)
+ #
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-stats.html
#
def stats(arguments={})
@@ -99,7 +101,8 @@ module Elasticsearch
:ignore_indices,
:ignore_unavailable,
:allow_no_indices,
- :expand_wildcards ]
+ :expand_wildcards,
+ :include_segment_file_sizes ]
method = HTTP_GET
@@ -107,8 +110,8 @@ module Elasticsearch
path = Utils.__pathify Utils.__listify(arguments[:index]), '_stats', Utils.__listify(parts)
params = Utils.__validate_and_extract_params arguments, valid_params
- params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
- params[:groups] = Utils.__listify(params[:groups]) if params[:groups]
+ params[:fields] = Utils.__listify(params[:fields], :escape => false) if params[:fields]
+ params[:groups] = Utils.__listify(params[:groups], :escape => false) if params[:groups]
body = nil
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb
index 2948fc4..4949e10 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb
@@ -13,9 +13,12 @@ module Elasticsearch
#
# client.indices.validate_query index: 'myindex', q: '[[[ BOOM! ]]]', explain: true
#
- # @example Validate a DSL query (with explanation)
+ # @example Validate a DSL query (with explanation and rewrite). With rewrite set to true, the
+ # explanation is more detailed showing the actual Lucene query that will
+ # be executed.
#
# client.indices.validate_query index: 'myindex',
+ # rewrite: true,
# explain: true,
# body: {
# filtered: {
@@ -64,6 +67,7 @@ module Elasticsearch
#
def validate_query(arguments={})
valid_params = [
+ :rewrite,
:explain,
:ignore_unavailable,
:allow_no_indices,
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb
index 71b7349..ec8ddce 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb
@@ -12,15 +12,11 @@ module Elasticsearch
# @see https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
#
def delete_pipeline(arguments={})
- Utils.__report_unsupported_method(__method__)
-
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
-
valid_params = [
:master_timeout,
:timeout ]
-
- method = HTTP_DELETE
+ method = 'DELETE'
path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id])
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_pipeline.rb
index 8b523fb..ec0e91b 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_pipeline.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_pipeline.rb
@@ -5,20 +5,15 @@ module Elasticsearch
# Return a specified pipeline
#
- # @option arguments [String] :id Comma separated list of pipeline ids. Wildcards supported (*Required*)
+ # @option arguments [String] :id Comma separated list of pipeline ids (wildcards supported).
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
#
# @see https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
#
def get_pipeline(arguments={})
- Utils.__report_unsupported_method(__method__)
-
- raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
-
valid_params = [
:master_timeout ]
-
- method = HTTP_GET
+ method = 'GET'
path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id])
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_pipeline.rb
index 1b846d1..ccc3252 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_pipeline.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_pipeline.rb
@@ -13,16 +13,12 @@ module Elasticsearch
# @see https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
#
def put_pipeline(arguments={})
- Utils.__report_unsupported_method(__method__)
-
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
-
valid_params = [
:master_timeout,
:timeout ]
-
- method = HTTP_PUT
+ method = 'PUT'
path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id])
params = Utils.__validate_and_extract_params arguments, valid_params
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb
index dd0f4d9..1109425 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb
@@ -13,13 +13,10 @@ module Elasticsearch
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html
#
def simulate(arguments={})
- Utils.__report_unsupported_method(__method__)
-
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
-
- valid_params = [ :verbose ]
-
- method = HTTP_GET
+ valid_params = [
+ :verbose ]
+ method = 'GET'
path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id]), '_simulate'
params = Utils.__validate_and_extract_params arguments, valid_params
body = arguments[:body]
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/mget.rb b/elasticsearch-api/lib/elasticsearch/api/actions/mget.rb
index b0baf45..b0444d3 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/mget.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/mget.rb
@@ -40,6 +40,7 @@ module Elasticsearch
# or a list of fields to return
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
+ # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
#
# @see http://elasticsearch.org/guide/reference/api/multi-get/
#
@@ -55,7 +56,8 @@ module Elasticsearch
:routing,
:_source,
:_source_include,
- :_source_exclude ]
+ :_source_exclude,
+ :stored_fields ]
method = HTTP_GET
path = Utils.__pathify Utils.__escape(arguments[:index]),
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/info.rb
index d41766c..a2c0834 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/info.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/info.rb
@@ -35,6 +35,7 @@ module Elasticsearch
# @option arguments [Boolean] :settings Return information about node settings
# @option arguments [Boolean] :thread_pool Return information about the thread pool
# @option arguments [Boolean] :transport Return information about transport
+ # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
# @option arguments [Time] :timeout Explicit operation timeout
#
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-info/
@@ -56,7 +57,7 @@ module Elasticsearch
:transport,
:timeout ]
- valid_params = [ :timeout ]
+ valid_params = [ :flat_settings, :timeout ]
method = HTTP_GET
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb
index 9739b3b..ce47072 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb
@@ -32,6 +32,7 @@ module Elasticsearch
# (supports wildcards)
# @option arguments [List] :fields A comma-separated list of fields for `fielddata` and `completion` index
# metrics (supports wildcards)
+ # @option arguments [Boolean] :include_segment_file_sizes Whether to report the aggregated disk usage of each one of the Lucene index files. Only applies if segment stats are requested. (default: false)
# @option arguments [Boolean] :groups A comma-separated list of search groups for `search` index metric
# @option arguments [Boolean] :human Whether to return time and byte values in human-readable format
# @option arguments [String] :level Specify the level for aggregating indices stats
@@ -51,6 +52,7 @@ module Elasticsearch
:completion_fields,
:fielddata_fields,
:fields,
+ :include_segment_file_sizes,
:groups,
:human,
:level,
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ping.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ping.rb
index 2527352..ceaf839 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/ping.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/ping.rb
@@ -2,7 +2,7 @@ module Elasticsearch
module API
module Actions
- # Returns true if the cluster returns a sucessfull HTTP response, false otherwise.
+ # Returns true if the cluster returns a successful HTTP response, false otherwise.
#
# @example
#
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb b/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb
index 22419be..6b5c35e 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb
@@ -7,7 +7,8 @@ module Elasticsearch
# When using `from` and `size` to return a large result sets, performance drops as you "paginate" in the set,
# and you can't guarantee the consistency when the index is being updated at the same time.
#
- # "Scrolling" the results is frequently used with the `scan` search type.
+ # The "Scroll" API uses a "point in time" snapshot of the index state, which was created via a "Search" API
+ # request specifying the `scroll` parameter.
#
# @example A basic example
#
@@ -24,8 +25,13 @@ module Elasticsearch
# 1_000.times do |i| client.index index: 'test', type: 'test', id: i+1, body: {title: "Test #{i}"} end
# client.indices.refresh index: 'test'
#
- # # Open the "view" of the index with the `scan` search_type
- # r = client.search index: 'test', search_type: 'scan', scroll: '5m', size: 10
+ # # Open the "view" of the index by passing the `scroll` parameter
+ # # Sorting by `_doc` makes the operations faster
+ # r = client.search index: 'test', scroll: '1m', body: {sort: ['_doc']}
+ #
+ # # Display the initial results
+ # puts "--- BATCH 0 -------------------------------------------------"
+ # puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect
#
# # Call the `scroll` API until empty results are returned
# while r = client.scroll(scroll_id: r['_scroll_id'], scroll: '5m') and not r['hits']['hits'].empty? do
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search.rb
index 8afacb8..b884327 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/search.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/search.rb
@@ -78,6 +78,9 @@ module Elasticsearch
# @option arguments [List] :fields A comma-separated list of fields to return as part of a hit
# @option arguments [List] :fielddata_fields A comma-separated list of fields to return as the field data
# representation of a field for each hit
+ # @option arguments [List] :docvalue_fields A comma-separated list of fields to return as the docvalue
+ # representation of a field for each hit
+ # @option arguments [List] :stored_fields A comma-separated list of stored fields to return as part of a hit
# @option arguments [Number] :from Starting offset (default: 0)
# @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
# (options: none, missing)
@@ -102,6 +105,7 @@ module Elasticsearch
# or a list of fields to return
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
+ # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
# @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
# @option arguments [String] :suggest_field Specify which field to use for suggestions
# @option arguments [String] :suggest_mode Specify suggest mode (options: missing, popular, always)
@@ -126,6 +130,8 @@ module Elasticsearch
:df,
:explain,
:fielddata_fields,
+ :docvalue_fields,
+ :stored_fields,
:fields,
:from,
:ignore_indices,
@@ -147,6 +153,7 @@ module Elasticsearch
:_source,
:_source_include,
:_source_exclude,
+ :stored_fields,
:stats,
:suggest_field,
:suggest_mode,
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get.rb
index adbcab8..944f9de 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get.rb
@@ -19,6 +19,7 @@ module Elasticsearch
#
# @option arguments [String] :repository A repository name (*Required*)
# @option arguments [List] :snapshot A comma-separated list of snapshot names (*Required*)
+ # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to # false which means a SnapshotMissingException is thrown
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
#
@@ -29,6 +30,7 @@ module Elasticsearch
raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]
valid_params = [
+ :ignore_unavailable,
:master_timeout ]
repository = arguments.delete(:repository)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb
index 45d2b61..ffe881b 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb
@@ -15,6 +15,7 @@ module Elasticsearch
#
# @option arguments [String] :repository A repository name
# @option arguments [List] :snapshot A comma-separated list of snapshot names
+ # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to # false which means a SnapshotMissingException is thrown
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
#
@@ -22,6 +23,7 @@ module Elasticsearch
#
def status(arguments={})
valid_params = [
+ :ignore_unavailable,
:master_timeout ]
repository = arguments.delete(:repository)
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/tasks/list.rb b/elasticsearch-api/lib/elasticsearch/api/actions/tasks/list.rb
index aa25a6d..4be05fd 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/tasks/list.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/tasks/list.rb
@@ -31,9 +31,6 @@ module Elasticsearch
:group_by,
:wait_for_completion ]
- unsupported_params = [ :group_by ]
- Utils.__report_unsupported_parameters(arguments.keys, unsupported_params)
-
task_id = arguments.delete(:task_id)
method = 'GET'
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/update.rb b/elasticsearch-api/lib/elasticsearch/api/actions/update.rb
index 58bc35f..cea5fae 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/update.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/update.rb
@@ -51,6 +51,10 @@ module Elasticsearch
# when a conflict occurs (default: 0)
# @option arguments [String] :routing Specific routing value
# @option arguments [String] :script The URL-encoded script definition (instead of using request body)
+ # @option arguments [String] :_source Specify whether the _source field should be returned,
+ # or a list of fields to return
+ # @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
+ # @option arguments [String] :_source_include A list of fields to extract and return from the _source field
# @option arguments [Time] :timeout Explicit operation timeout
# @option arguments [Time] :timestamp Explicit timestamp for the document
# @option arguments [Duration] :ttl Expiration time for the document
@@ -77,6 +81,9 @@ module Elasticsearch
:retry_on_conflict,
:routing,
:script,
+ :_source,
+ :_source_include,
+ :_source_exclude,
:timeout,
:timestamp,
:ttl,
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb
index 10d4b45..4648d1a 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb
@@ -111,9 +111,6 @@ module Elasticsearch
:wait_for_completion,
:requests_per_second ]
- unsupported_params = [ :pipeline ]
- Utils.__report_unsupported_parameters(arguments, unsupported_params)
-
method = HTTP_POST
path = Utils.__pathify Utils.__listify(arguments[:index]),
diff --git a/elasticsearch-api/lib/elasticsearch/api/utils.rb b/elasticsearch-api/lib/elasticsearch/api/utils.rb
index 5b4418e..38504a7 100644
--- a/elasticsearch-api/lib/elasticsearch/api/utils.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/utils.rb
@@ -235,7 +235,7 @@ module Elasticsearch
end
unless messages.empty?
- if terminal = STDERR.tty?
+ if STDERR.tty?
STDERR.puts messages.map { |m| "\e[31;1m#{m}\e[0m" }.join("\n")
else
STDERR.puts messages.join("\n")
@@ -251,11 +251,11 @@ module Elasticsearch
message += ". This method is not supported in the version you're using: #{Elasticsearch::API::VERSION}, and will be removed in the next release."
- if terminal = STDERR.tty?
- STDERR.puts "\e[31;1m#{message}\e[0m"
- else
- STDERR.puts message
- end
+ if STDERR.tty?
+ STDERR.puts "\e[31;1m#{message}\e[0m"
+ else
+ STDERR.puts message
+ end
end
extend self
diff --git a/elasticsearch-api/lib/elasticsearch/api/version.rb b/elasticsearch-api/lib/elasticsearch/api/version.rb
index 5bd0814..9f4c9aa 100644
--- a/elasticsearch-api/lib/elasticsearch/api/version.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/version.rb
@@ -1,5 +1,5 @@
module Elasticsearch
module API
- VERSION = "2.0.0"
+ VERSION = "5.0.1"
end
end
diff --git a/elasticsearch-api/test/integration/yaml_test_runner.rb b/elasticsearch-api/test/integration/yaml_test_runner.rb
index ba3277f..44183b5 100644
--- a/elasticsearch-api/test/integration/yaml_test_runner.rb
+++ b/elasticsearch-api/test/integration/yaml_test_runner.rb
@@ -14,7 +14,7 @@ require 'elasticsearch/extensions/test/startup_shutdown'
require 'elasticsearch/extensions/test/profiling' unless JRUBY
# Skip features
-skip_features = 'stash_in_path,requires_replica,headers'
+skip_features = 'stash_in_path,requires_replica,headers,warnings'
SKIP_FEATURES = ENV.fetch('TEST_SKIP_FEATURES', skip_features)
# Turn configuration
@@ -24,8 +24,7 @@ Turn.config.format = :pretty
# Launch test cluster
#
if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
- es_params = "-D es.repositories.url.allowed_urls=http://snapshot.test* -D es.path.repo=/tmp -D es.node.testattr=test " + ENV['TEST_CLUSTER_PARAMS'].to_s
- Elasticsearch::Extensions::Test::Cluster.start(nodes: 1, es_params: es_params )
+ Elasticsearch::Extensions::Test::Cluster.start
end
# Register `at_exit` handler for server shutdown.
@@ -232,38 +231,44 @@ module Elasticsearch
skip = actions.select { |a| a['skip'] }.first
$stderr.puts "SKIP: #{skip.inspect}" if ENV['DEBUG']
- # Skip version
- if skip && skip['skip']['version']
+ def skip_version(skip)
+ if skip && skip['skip']['version']
- return skip['skip']['reason'] ? skip['skip']['reason'] : true if skip['skip']['version'] == 'all'
+ return skip['skip']['reason'] ? skip['skip']['reason'] : true if skip['skip']['version'] == 'all'
- min, max = skip['skip']['version'].split('-').map(&:strip)
+ min, max = skip['skip']['version'].split('-').map(&:strip)
- min_normalized = sprintf "%03d-%03d-%03d",
- *min.split('.')
- .map(&:to_i)
- .fill(0, min.split('.').length, 3-min.split('.').length)
+ min_normalized = sprintf "%03d-%03d-%03d",
+ *min.split('.')
+ .map(&:to_i)
+ .fill(0, min.split('.').length, 3-min.split('.').length)
- max_normalized = sprintf "%03d-%03d-%03d",
- *max.split('.')
- .map(&:to_i)
- .map(&:to_i)
- .fill(0, max.split('.').length, 3-max.split('.').length)
+ max_normalized = sprintf "%03d-%03d-%03d",
+ *max.split('.')
+ .map(&:to_i)
+ .map(&:to_i)
+ .fill(0, max.split('.').length, 3-max.split('.').length)
- es_normalized = sprintf "%03d-%03d-%03d", *$es_version.split('.').map(&:to_i)
+ es_normalized = sprintf "%03d-%03d-%03d", *$es_version.split('.').map(&:to_i)
- if ( min.empty? || min_normalized <= es_normalized ) && ( max.empty? || max_normalized >= es_normalized )
- return skip['skip']['reason'] ? skip['skip']['reason'] : true
+ if ( min.empty? || min_normalized <= es_normalized ) && ( max.empty? || max_normalized >= es_normalized )
+ return skip['skip']['reason'] ? skip['skip']['reason'] : true
+ end
+
+ return false
end
+ end
- # Skip features
- elsif skip && skip['skip']['features']
- if (skip['skip']['features'].split(',') & SKIP_FEATURES.split(',') ).size > 0
- return skip['skip']['features']
+ def skip_features(skip)
+ if skip && skip['skip']['features']
+ skip_features = skip['skip']['features'].respond_to?(:split) ? skip['skip']['features'].split(',') : skip['skip']['features']
+ if ( skip_features & SKIP_FEATURES.split(',') ).size > 0
+ return skip['skip']['features']
+ end
end
end
- return false
+ return skip_version(skip) || skip_features(skip)
end
extend self
@@ -299,12 +304,20 @@ suites.each do |suite|
$client.snapshot.delete_repository repository: 'test_repo_restore_1', ignore: 404
$client.snapshot.delete_repository repository: 'test_repo_get_1', ignore: 404
$client.snapshot.delete_repository repository: 'test_repo_get_2', ignore: 404
+ $client.snapshot.delete_repository repository: 'test_repo_status_1', ignore: 404
$client.snapshot.delete_repository repository: 'test_cat_repo_1', ignore: 404
$client.snapshot.delete_repository repository: 'test_cat_repo_2', ignore: 404
$client.snapshot.delete_repository repository: 'test_cat_snapshots_1', ignore: 404
# FIXME: This shouldn't be needed -------------
- FileUtils.rm_rf('/tmp/test_repo_create_1_loc')
- FileUtils.rm_rf('/tmp/test_repo_restore_1_loc')
+ %w[
+ test_cat_repo_1_loc
+ test_cat_repo_2_loc
+ test_cat_snapshots_1_loc
+ test_repo_get_1_loc
+ test_repo_status_1_loc
+ ].each do |d|
+ FileUtils.rm_rf("/tmp/#{d}")
+ end
# ---------------------------------------------
$results = {}
$stash = {}
@@ -347,7 +360,8 @@ suites.each do |suite|
# --- Register test setup -------------------------------------------
setup do
- actions.select { |a| a['setup'] }.first['setup'].each do |action|
+ setup_actions = actions.select { |a| a['setup'] }
+ setup_actions.first['setup'].each do |action|
if action['do']
api, arguments = action['do'].to_a.first
arguments = Utils.symbolize_keys(arguments)
@@ -360,7 +374,25 @@ suites.each do |suite|
$stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
Runner.set variable, result
end
- end
+ end unless setup_actions.empty?
+ end
+
+ teardown do
+ teardown_actions = actions.select { |a| a['teardown'] }
+ teardown_actions.first['teardown'].each do |action|
+ if action['do']
+ api, arguments = action['do'].to_a.first
+ arguments = Utils.symbolize_keys(arguments)
+ Runner.perform_api_call((test.to_s + '___teardown'), api, arguments)
+ end
+ if action['set']
+ stash = action['set']
+ property, variable = stash.to_a.first
+ result = Runner.evaluate(test, property, $last_response)
+ $stderr.puts "STASH: '$#{variable}' => #{result.inspect}" if ENV['DEBUG']
+ Runner.set variable, result
+ end
+ end unless teardown_actions.empty?
end
# --- Register test method ------------------------------------------
@@ -374,6 +406,10 @@ suites.each do |suite|
actions.each do |action|
$stderr.puts "ACTION: #{action.inspect}" if ENV['DEBUG']
+ # This check verifies that the YAML has correct indentation.
+ # See https://github.com/elastic/elasticsearch/issues/21980
+ raise "INVALID YAML: #{action.inspect}" if action.keys.size != 1
+
case
# --- Perform action ------------------------------------------
@@ -458,16 +494,23 @@ suites.each do |suite|
$stderr.puts "CHECK: Expected '#{property}' to be #{value}, is: #{length.inspect}" if ENV['DEBUG']
assert_equal(value, length)
- when a = action['lt'] || action['gt']
- next
+ when a = action['lt'] || action['gt'] || action['lte'] || action['gte']
property, value = a.to_a.first
- operator = action['lt'] ? '<' : '>'
+ operator = case
+ when action['lt']
+ '<'
+ when action['gt']
+ '>'
+ when action['lte']
+ '<='
+ when action['gte']
+ '>='
+ end
result = Runner.evaluate(test, property)
message = "Expected '#{property}' to be #{operator} #{value}, is: #{result.inspect}"
$stderr.puts "CHECK: #{message}" if ENV['DEBUG']
- # operator == 'less than' ? assert(value.to_f < result.to_f, message) : assert(value.to_f > result.to_f, message)
assert_operator result, operator.to_sym, value.to_i
when stash = action['set']
diff --git a/elasticsearch-api/test/unit/cat/templates_test.rb b/elasticsearch-api/test/unit/cat/templates_test.rb
new file mode 100644
index 0000000..dd0d076
--- /dev/null
+++ b/elasticsearch-api/test/unit/cat/templates_test.rb
@@ -0,0 +1,26 @@
+require 'test_helper'
+
+module Elasticsearch
+ module Test
+ class CatTemplatesTest < ::Test::Unit::TestCase
+
+ context "Cat: Templates" do
+ subject { FakeClient.new }
+
+ should "perform correct request" do
+ subject.expects(:perform_request).with do |method, url, params, body|
+ assert_equal 'GET', method
+ assert_equal '_cat/templates', url
+ assert_equal Hash.new, params
+ assert_nil body
+ true
+ end.returns(FakeResponse.new)
+
+ subject.cat.templates
+ end
+
+ end
+
+ end
+ end
+end
diff --git a/elasticsearch-api/test/unit/delete_by_query_test.rb b/elasticsearch-api/test/unit/delete_by_query_test.rb
index 45ac552..2dee265 100644
--- a/elasticsearch-api/test/unit/delete_by_query_test.rb
+++ b/elasticsearch-api/test/unit/delete_by_query_test.rb
@@ -15,8 +15,8 @@ module Elasticsearch
should "perform correct request" do
subject.expects(:perform_request).with do |method, url, params, body|
- assert_equal 'DELETE', method
- assert_equal 'foo/_query', url
+ assert_equal 'POST', method
+ assert_equal 'foo/_delete_by_query', url
assert_equal Hash.new, params
assert_equal Hash.new, body[:term]
true
@@ -27,7 +27,7 @@ module Elasticsearch
should "optionally take the :type argument" do
subject.expects(:perform_request).with do |method, url, params, body|
- assert_equal 'foo/tweet,post/_query', url
+ assert_equal 'foo/tweet,post/_delete_by_query', url
true
end.returns(FakeResponse.new)
@@ -36,7 +36,7 @@ module Elasticsearch
should "pass the query in URL parameters" do
subject.expects(:perform_request).with do |method, url, params, body|
- assert_equal 'foo/_query', url
+ assert_equal 'foo/_delete_by_query', url
assert_equal 'foo:bar', params[:q]
true
end.returns(FakeResponse.new)
diff --git a/elasticsearch-api/test/unit/indices/rollover_test.rb b/elasticsearch-api/test/unit/indices/rollover_test.rb
new file mode 100644
index 0000000..e3d0189
--- /dev/null
+++ b/elasticsearch-api/test/unit/indices/rollover_test.rb
@@ -0,0 +1,38 @@
+require 'test_helper'
+
+module Elasticsearch
+ module Test
+ class IndicesRolloverTest < ::Test::Unit::TestCase
+
+ context "Indices: Rollover" do
+ subject { FakeClient.new }
+
+ should "perform correct request" do
+ subject.expects(:perform_request).with do |method, url, params, body|
+ assert_equal 'POST', method
+ assert_equal 'foo/_rollover', url
+ assert_equal Hash.new, params
+ assert_equal nil, body
+ true
+ end.returns(FakeResponse.new)
+
+ subject.indices.rollover :alias => 'foo'
+ end
+
+ should "customize the index" do
+ subject.expects(:perform_request).with do |method, url, params, body|
+ assert_equal 'POST', method
+ assert_equal 'foo/_rollover/bar', url
+ assert_equal Hash.new, params
+ assert_equal nil, body
+ true
+ end.returns(FakeResponse.new)
+
+ subject.indices.rollover :alias => 'foo', :new_index => 'bar'
+ end
+
+ end
+
+ end
+ end
+end
diff --git a/elasticsearch-api/test/unit/indices/shrink_test.rb b/elasticsearch-api/test/unit/indices/shrink_test.rb
new file mode 100644
index 0000000..efdc673
--- /dev/null
+++ b/elasticsearch-api/test/unit/indices/shrink_test.rb
@@ -0,0 +1,33 @@
+require 'test_helper'
+
+module Elasticsearch
+ module Test
+ class IndicesShrinkTest < ::Test::Unit::TestCase
+
+ context "Indices: Shrink" do
+ subject { FakeClient.new }
+
+ should "perform correct request" do
+ subject.expects(:perform_request).with do |method, url, params, body|
+ assert_equal 'PUT', method
+ assert_equal 'foo/_shrink/bar', url
+ assert_equal nil, body
+ true
+ end.returns(FakeResponse.new)
+
+ subject.indices.shrink :index => 'foo', :target => 'bar'
+ end
+
+ should "not change the arguments" do
+ arguments = { :index => 'foo', :target => 'bar', :body => { :settings => {} } }
+ subject.indices.shrink arguments
+
+ assert_not_nil arguments[:index]
+ assert_not_nil arguments[:target]
+ end
+
+ end
+
+ end
+ end
+end
diff --git a/elasticsearch-api/test/unit/ingest/get_pipeline_test.rb b/elasticsearch-api/test/unit/ingest/get_pipeline_test.rb
index b779dd8..686adef 100644
--- a/elasticsearch-api/test/unit/ingest/get_pipeline_test.rb
+++ b/elasticsearch-api/test/unit/ingest/get_pipeline_test.rb
@@ -7,12 +7,6 @@ module Elasticsearch
context "Ingest: Get pipeline" do
subject { FakeClient.new }
- should "require the :id argument" do
- assert_raise ArgumentError do
- subject.ingest.get_pipeline
- end
- end
-
should "perform correct request" do
subject.expects(:perform_request).with do |method, url, params, body|
assert_equal 'GET', method
diff --git a/elasticsearch-api/utils/thor/generate_source.rb b/elasticsearch-api/utils/thor/generate_source.rb
index 7162bbc..829b34d 100644
--- a/elasticsearch-api/utils/thor/generate_source.rb
+++ b/elasticsearch-api/utils/thor/generate_source.rb
@@ -62,6 +62,18 @@ module Elasticsearch
@namespace_depth = @full_namespace.size > 0 ? @full_namespace.size-1 : 0
@module_namespace = @full_namespace[0, @namespace_depth]
@method_name = @full_namespace.last
+ @http_method = "HTTP_#{@spec['methods'].first}"
+ @http_path = unless @spec['url']['parts'].empty?
+ @spec['url']['path']
+ .split('/')
+ .compact
+ .reject { |p| p =~ /^\s*$/ }
+ .map { |p| p =~ /\{/ ? "\#\{arguments[:#{p.tr('{}', '')}]\}" : p }
+ .join('/')
+ .gsub(/^\//, '')
+ else
+ @spec['url']['path'].gsub(/^\//, '')
+ end
# -- Ruby files
diff --git a/elasticsearch-api/utils/thor/templates/ruby/method.erb b/elasticsearch-api/utils/thor/templates/ruby/method.erb
index 863efc8..dbbe3a2 100644
--- a/elasticsearch-api/utils/thor/templates/ruby/method.erb
+++ b/elasticsearch-api/utils/thor/templates/ruby/method.erb
@@ -1,7 +1,7 @@
module Elasticsearch
module API
<%- @module_namespace.each_with_index do |name, i| -%>
- <%= ' '*i %>module <%= name.capitalize %>
+ <%= ' '*i %>module <%= name == 'xpack' ? 'XPack' : name.capitalize %>
<%- end -%>
<%= ' '*@namespace_depth %>module Actions
@@ -35,17 +35,13 @@ module Elasticsearch
<%= ' '*(@namespace_depth+1) + "raise ArgumentError, \"Required argument 'body' missing\" unless arguments[:body]" + "\n" -%>
<%- end -%>
<%# Method, path, params, body -%>
+ <%- unless @spec['url']['params'].empty? -%>
<%= ' '*@namespace_depth %> valid_params = [
<%= ' '*(@namespace_depth+2) %><%= @spec['url']['params'].keys.map { |k| ":#{k}" }.join(",\n#{' '*(@namespace_depth+5)}") %> ]
- <%= ' '*@namespace_depth %> method = '<%= @spec['methods'].first %>'
- <%- unless @spec['url']['parts'].empty? -%>
- <%= ' '*@namespace_depth %> path = "<%= @spec['url']['path'].split('/').compact.reject {|p| p =~ /^\s*$/}.map do |p|
- p =~ /\{/ ? "\#\{arguments[:#{p.tr('{}', '')}]\}" : p
- end.join('/') %>"
- <%- else -%>
- <%= ' '*@namespace_depth %> path = "<%= @spec['url']['path'] %>"
<%- end -%>
- <%- unless @spec['url']['params'].keys.empty? -%>
+ <%= ' '*@namespace_depth %> method = <%= @http_method %>
+ <%= ' '*@namespace_depth %> path = "<%= @http_path %>"
+ <%- unless @spec['url']['params'].empty? -%>
<%= ' '*@namespace_depth %> params = Utils.__validate_and_extract_params arguments, valid_params
<%- else -%>
<%= ' '*@namespace_depth %> params = {}
diff --git a/elasticsearch-api/utils/thor/templates/ruby/test.erb b/elasticsearch-api/utils/thor/templates/ruby/test.erb
index abe6cee..fd2a0da 100644
--- a/elasticsearch-api/utils/thor/templates/ruby/test.erb
+++ b/elasticsearch-api/utils/thor/templates/ruby/test.erb
@@ -2,9 +2,9 @@ require 'test_helper'
module Elasticsearch
module Test
- class <%= @module_namespace.empty? ? @method_name.camelize : @module_namespace.map {|n| n.capitalize}.join + @method_name.camelize %>Test < ::Test::Unit::TestCase
+ class <%= @module_namespace.map {|n| n.capitalize}.map { |n| n == 'Xpack' ? 'XPack' : n }.join('') + @method_name.camelize %>Test < ::Test::Unit::TestCase
- context "<%= @module_namespace.empty? ? '' : @module_namespace.map {|n| n.capitalize}.join + ': ' %><%= @method_name.humanize %>" do
+ context "<%= @module_namespace.map {|n| n.capitalize}.map { |n| n == 'Xpack' ? 'XPack' : n }.join(' ') + ': ' %><%= @method_name.humanize %>" do
subject { FakeClient.new }
should "perform correct request" do
@@ -16,7 +16,7 @@ module Elasticsearch
true
end.returns(FakeResponse.new)
- subject.<%= @full_namespace.join('.') %>
+ subject.<%= @full_namespace.join('.') %> <%= @spec['url']['parts'].select { |name, info| info['required'] }.keys.map { |d| ":#{d} => 'foo'" }.join(', ') %>
end
end
diff --git a/elasticsearch-dsl/Gemfile b/elasticsearch-dsl/Gemfile
index 09bb3c3..2665ffb 100644
--- a/elasticsearch-dsl/Gemfile
+++ b/elasticsearch-dsl/Gemfile
@@ -3,18 +3,18 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in elasticsearch-dsl.gemspec
gemspec
-if File.exists? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
gem 'elasticsearch', :path => File.expand_path("../../elasticsearch", __FILE__), :require => false
end
-if File.exists? File.expand_path("../../elasticsearch-transport", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-transport", __FILE__)
gem 'elasticsearch-transport', :path => File.expand_path("../../elasticsearch-transport", __FILE__), :require => true
end
-if File.exists? File.expand_path("../../elasticsearch-api", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-api", __FILE__)
gem 'elasticsearch-api', :path => File.expand_path("../../elasticsearch-api", __FILE__), :require => false
end
-if File.exists? File.expand_path("../../elasticsearch-extensions", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-extensions", __FILE__)
gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => false
end
diff --git a/elasticsearch-dsl/Rakefile b/elasticsearch-dsl/Rakefile
index 0ae8646..b48ce03 100644
--- a/elasticsearch-dsl/Rakefile
+++ b/elasticsearch-dsl/Rakefile
@@ -11,13 +11,15 @@ namespace :test do
Rake::TestTask.new(:unit) do |test|
test.libs << 'lib' << 'test'
test.test_files = FileList["test/unit/**/*_test.rb"]
- # test.verbose = true
- # test.warning = true
+ test.verbose = false
+ test.warning = false
end
Rake::TestTask.new(:integration) do |test|
test.libs << 'lib' << 'test'
test.test_files = FileList["test/integration/**/*_test.rb"]
+ test.verbose = false
+ test.warning = false
end
desc "Run unit and integration tests"
diff --git a/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/bool.rb b/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/bool.rb
index 63bbec2..acb9029 100644
--- a/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/bool.rb
+++ b/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/bool.rb
@@ -36,6 +36,9 @@ module Elasticsearch
class Bool
include BaseComponent
+ option_method :minimum_should_match
+ option_method :boost
+
def must(*args, &block)
@hash[name][:must] ||= []
value = Query.new(*args, &block).to_hash
@@ -58,7 +61,9 @@ module Elasticsearch
end
def filter(*args, &block)
- @filter = block ? Filter.new(*args, &block) : args.first
+ @hash[name][:filter] ||= []
+ value = Filter.new(*args, &block).to_hash
+ @hash[name][:filter].push(value).flatten! unless @hash[name][:filter].include?(value)
self
end
@@ -71,11 +76,6 @@ module Elasticsearch
@hash[name] = @args unless @args.nil? || @args.empty?
end
- if @filter
- _filter = @filter.respond_to?(:to_hash) ? @filter.to_hash : @filter
- @hash[name].update(filter: _filter)
- end
-
@hash
end
end
diff --git a/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/exists.rb b/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/exists.rb
new file mode 100644
index 0000000..c0473f3
--- /dev/null
+++ b/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/exists.rb
@@ -0,0 +1,44 @@
+module Elasticsearch
+ module DSL
+ module Search
+ module Queries
+
+ # Returns documents that have at least one non-null value in the field.
+ #
+ # @example Find documents with non-empty "name" property
+ #
+ # search do
+ # query do
+ # exists do
+ # field 'name'
+ # end
+ # end
+ # end
+ #
+ # @note The "Exists" query can be used as a "Missing" query in a "Bool" query "Must Not" context.
+ #
+ # @example Find documents with an empty "name" property
+ #
+ # search do
+ # query do
+ # bool do
+ # must_not do
+ # exists do
+ # field 'name'
+ # end
+ # end
+ # end
+ # end
+ # end
+ #
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-exists-query.html
+ #
+ class Exists
+ include BaseComponent
+
+ option_method :field
+ end
+ end
+ end
+ end
+end
diff --git a/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/more_like_this.rb b/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/more_like_this.rb
index baaf83d..d89a3ef 100644
--- a/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/more_like_this.rb
+++ b/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/more_like_this.rb
@@ -10,7 +10,7 @@ module Elasticsearch
# search do
# query do
# more_like_this do
- # like_text 'Eyjafjallajökull'
+ # like ['Eyjafjallajökull']
# fields [:title, :abstract, :content]
# end
# end
@@ -22,7 +22,7 @@ module Elasticsearch
# search do
# query do
# more_like_this do
- # ids [1, 2, 3]
+ # like [{_id: 1}, {_id: 2}, {_id: 3}]
# fields [:title, :abstract]
# end
# end
@@ -33,12 +33,18 @@ module Elasticsearch
class MoreLikeThis
include BaseComponent
- option_method :fields
+ # like/unlike is since 2.0.0
+ option_method :like
+ option_method :unlike
+
+ # before 2.0.0 the following 3 options were available
option_method :like_text
- option_method :min_term_freq
- option_method :max_query_terms
option_method :docs
option_method :ids
+
+ option_method :fields
+ option_method :min_term_freq
+ option_method :max_query_terms
option_method :include
option_method :exclude
option_method :percent_terms_to_match
diff --git a/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/nested.rb b/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/nested.rb
index d55fbad..65991f7 100644
--- a/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/nested.rb
+++ b/elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/nested.rb
@@ -25,6 +25,7 @@ module Elasticsearch
option_method :path
option_method :score_mode
+ option_method :inner_hits
# DSL method for building the `query` part of the query definition
#
diff --git a/elasticsearch-dsl/test/integration/search_query_test.rb b/elasticsearch-dsl/test/integration/search_query_test.rb
index 46ae384..bf1fef8 100644
--- a/elasticsearch-dsl/test/integration/search_query_test.rb
+++ b/elasticsearch-dsl/test/integration/search_query_test.rb
@@ -47,6 +47,22 @@ module Elasticsearch
assert_equal 2, response['hits']['total']
assert_equal 'Test', response['hits']['hits'][0]['_source']['title']
end
+
+ should "find the document with a filter" do
+ skip "Not supported on this Elasticsearch version" unless @version > '2'
+
+ response = @client.search index: 'test', body: search {
+ query do
+ bool do
+ filter { terms tags: ['one'] }
+ filter { terms tags: ['two'] }
+ end
+ end
+ }.to_hash
+
+ assert_equal 1, response['hits']['total']
+ assert_equal 'Rest', response['hits']['hits'][0]['_source']['title']
+ end
end
end
diff --git a/elasticsearch-dsl/test/test_helper.rb b/elasticsearch-dsl/test/test_helper.rb
index 8b0a844..61bd434 100644
--- a/elasticsearch-dsl/test/test_helper.rb
+++ b/elasticsearch-dsl/test/test_helper.rb
@@ -52,6 +52,7 @@ module Elasticsearch
end
@client = Elasticsearch::Client.new host: "localhost:#{@port}", logger: @logger
+ @version = @client.info['version']['number']
end
def teardown
diff --git a/elasticsearch-dsl/test/unit/queries/bool_test.rb b/elasticsearch-dsl/test/unit/queries/bool_test.rb
index 14d9bb5..3f8b9b9 100644
--- a/elasticsearch-dsl/test/unit/queries/bool_test.rb
+++ b/elasticsearch-dsl/test/unit/queries/bool_test.rb
@@ -27,17 +27,38 @@ module Elasticsearch
assert_equal( { bool: {must: [ {match: { foo: 'bar' }} ] } }, subject.to_hash )
end
+ should "have option methods" do
+ subject = Bool.new do
+ should { term tag: 'wow' }
+ should { term tag: 'elasticsearch' }
+
+ minimum_should_match 1
+ boost 1.0
+ end
+
+ assert_equal( { bool:
+ {
+ minimum_should_match: 1,
+ boost: 1.0,
+ should: [ {term: { tag: 'wow' }}, {term: { tag: 'elasticsearch' }} ]
+ }
+ },
+ subject.to_hash )
+ end
+
should "take a block with multiple methods" do
subject = Bool.new do
must { match foo: 'bar' }
must_not { match moo: 'bam' }
should { match xoo: 'bax' }
+ filter { term zoo: 'baz'}
end
assert_equal( { bool:
{ must: [ {match: { foo: 'bar' }} ],
must_not: [ {match: { moo: 'bam' }} ],
- should: [ {match: { xoo: 'bax' }} ]
+ should: [ {match: { xoo: 'bax' }} ],
+ filter: [ {term: { zoo: 'baz' }}]
}
},
subject.to_hash )
@@ -92,13 +113,23 @@ module Elasticsearch
subject.to_hash )
end
- should "allow adding a filter" do
+ should "combine chained filters" do
subject = Bool.new
- subject.filter do
- term foo: 'bar'
- end
+ subject.
+ filter {
+ term foo: "bar"
+ }
+ subject.filter {
+ term zoo: "baz"
+ }
- assert_equal( { bool: { filter: { term: { foo: "bar" } } } }, subject.to_hash)
+ assert_equal( { bool:
+ { filter: [
+ { term: { foo: "bar"}},
+ { term: { zoo: "baz"}}
+ ] }
+ },
+ subject.to_hash)
end
should "be chainable" do
diff --git a/elasticsearch-dsl/test/unit/queries/exists_test.rb b/elasticsearch-dsl/test/unit/queries/exists_test.rb
new file mode 100644
index 0000000..bf9f061
--- /dev/null
+++ b/elasticsearch-dsl/test/unit/queries/exists_test.rb
@@ -0,0 +1,36 @@
+require 'test_helper'
+
+module Elasticsearch
+ module Test
+ module Queries
+ class ExistsTest < ::Test::Unit::TestCase
+ include Elasticsearch::DSL::Search::Queries
+
+ context "Exists query" do
+ subject { Exists.new }
+
+ should "be converted to a Hash" do
+ assert_equal({ exists: {} }, subject.to_hash)
+ end
+
+ should "have option methods" do
+ subject = Exists.new
+
+ subject.field 'bar'
+
+ assert_equal %w[ field ],
+ subject.to_hash[:exists].keys.map(&:to_s).sort
+ assert_equal 'bar', subject.to_hash[:exists][:field]
+ end
+
+ should "take a block" do
+ subject = Exists.new do
+ field 'bar'
+ end
+ assert_equal({ exists: { field: 'bar' } }, subject.to_hash)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/elasticsearch-dsl/test/unit/queries/nested_test.rb b/elasticsearch-dsl/test/unit/queries/nested_test.rb
index bce43e3..403fa20 100644
--- a/elasticsearch-dsl/test/unit/queries/nested_test.rb
+++ b/elasticsearch-dsl/test/unit/queries/nested_test.rb
@@ -19,10 +19,12 @@ module Elasticsearch
subject.path 'bar'
subject.score_mode 'bar'
subject.query 'bar'
+ subject.inner_hits({ size: 1 })
- assert_equal %w[ path query score_mode ],
+ assert_equal %w[ inner_hits path query score_mode ],
subject.to_hash[:nested].keys.map(&:to_s).sort
assert_equal 'bar', subject.to_hash[:nested][:path]
+ assert_equal({ size: 1 }, subject.to_hash[:nested][:inner_hits])
end
should "take the query as a Hash" do
diff --git a/elasticsearch-extensions/Gemfile b/elasticsearch-extensions/Gemfile
index 3910fae..ec2b4e6 100644
--- a/elasticsearch-extensions/Gemfile
+++ b/elasticsearch-extensions/Gemfile
@@ -3,18 +3,14 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in elasticsearch-extensions.gemspec
gemspec
-if File.exists? File.expand_path("../../elasticsearch-api/elasticsearch-api.gemspec", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-api/elasticsearch-api.gemspec", __FILE__)
gem 'elasticsearch-api', :path => File.expand_path("../../elasticsearch-api", __FILE__), :require => false
end
-if File.exists? File.expand_path("../../elasticsearch-transport/elasticsearch-transport.gemspec", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-transport/elasticsearch-transport.gemspec", __FILE__)
gem 'elasticsearch-transport', :path => File.expand_path("../../elasticsearch-transport", __FILE__), :require => false
end
-if File.exists? File.expand_path("../../elasticsearch-extensions", __FILE__)
- gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => false
-end
-
-if File.exists? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
gem 'elasticsearch', :path => File.expand_path("../../elasticsearch/", __FILE__)
end
diff --git a/elasticsearch-extensions/README.md b/elasticsearch-extensions/README.md
index b385159..d224709 100644
--- a/elasticsearch-extensions/README.md
+++ b/elasticsearch-extensions/README.md
@@ -136,10 +136,10 @@ Start the cluster on specific port, with a specific Elasticsearch version, numbe
require 'elasticsearch/extensions/test/cluster'
Elasticsearch::Extensions::Test::Cluster.start \
- cluster_name: "my-testing-cluster",
- command: "/usr/local/Cellar/elasticsearch/0.90.10/bin/elasticsearch",
- port: 9350,
- nodes: 3
+ cluster_name: "my-testing-cluster",
+ command: "/usr/local/Cellar/elasticsearch/0.90.10/bin/elasticsearch",
+ port: 9350,
+ number_of_nodes: 3
# Starting 3 Elasticsearch nodes.....................
# --------------------------------------------------------------------------------
diff --git a/elasticsearch-extensions/elasticsearch-extensions.gemspec b/elasticsearch-extensions/elasticsearch-extensions.gemspec
index d7f429f..70719fb 100644
--- a/elasticsearch-extensions/elasticsearch-extensions.gemspec
+++ b/elasticsearch-extensions/elasticsearch-extensions.gemspec
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.add_dependency "ansi"
- unless File.exists? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
+ unless File.exist? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
s.add_dependency "elasticsearch"
end
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "ci_reporter", "~> 1.9"
if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
- s.add_development_dependency "json"
+ s.add_development_dependency "json", '~> 1.8'
end
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
diff --git a/elasticsearch-extensions/lib/elasticsearch/extensions/reindex.rb b/elasticsearch-extensions/lib/elasticsearch/extensions/reindex.rb
index fdfbe1d..bf844b9 100644
--- a/elasticsearch-extensions/lib/elasticsearch/extensions/reindex.rb
+++ b/elasticsearch-extensions/lib/elasticsearch/extensions/reindex.rb
@@ -125,28 +125,21 @@ module Elasticsearch
response = arguments[:source][:client].search(
index: arguments[:source][:index],
scroll: arguments[:scroll],
- size: arguments[:batch_size],
- search_type: 'scan',
- fields: ['_source', '_parent', '_routing', '_timestamp']
+ size: arguments[:batch_size]
)
+ documents = response['hits']['hits']
+
+ unless documents.empty?
+ bulk_response = __store_batch(documents)
+ output[:errors] += bulk_response['items'].select { |k, v| k.values.first['error'] }.size
+ end
+
while response = arguments[:source][:client].scroll(scroll_id: response['_scroll_id'], scroll: arguments[:scroll]) do
documents = response['hits']['hits']
break if documents.empty?
- bulk = documents.map do |doc|
- doc['_index'] = arguments[:target][:index]
-
- arguments[:transform].call(doc) if arguments[:transform]
-
- doc['data'] = doc['_source']
- doc.delete('_score')
- doc.delete('_source')
-
- { index: doc }
- end
-
- bulk_response = arguments[:target][:client].bulk body: bulk
+ bulk_response = __store_batch(documents)
output[:errors] += bulk_response['items'].select { |k, v| k.values.first['error'] }.size
end
@@ -154,6 +147,22 @@ module Elasticsearch
output
end
+
+ def __store_batch(documents)
+ body = documents.map do |doc|
+ doc['_index'] = arguments[:target][:index]
+
+ arguments[:transform].call(doc) if arguments[:transform]
+
+ doc['data'] = doc['_source']
+ doc.delete('_score')
+ doc.delete('_source')
+
+ { index: doc }
+ end
+
+ arguments[:target][:client].bulk body: body
+ end
end
end
end
diff --git a/elasticsearch-extensions/lib/elasticsearch/extensions/test/cluster.rb b/elasticsearch-extensions/lib/elasticsearch/extensions/test/cluster.rb
index 1d8ef9b..c8ea354 100644
--- a/elasticsearch-extensions/lib/elasticsearch/extensions/test/cluster.rb
+++ b/elasticsearch-extensions/lib/elasticsearch/extensions/test/cluster.rb
@@ -24,9 +24,20 @@ module Elasticsearch
# A convenience Ruby class for starting and stopping an Elasticsearch cluster,
# eg. for integration tests
#
- # @example Start a cluster with default configuration
+ # @example Start a cluster with default configuration,
+ # assuming `elasticsearch` is on $PATH.
+ #
# require 'elasticsearch/extensions/test/cluster'
- # Elasticsearch::Extensions::Test::Cluster::Cluster.new.start
+ # Elasticsearch::Extensions::Test::Cluster.start
+ #
+ # @example Start a cluster with a specific Elasticsearch launch script,
+ # eg. from a downloaded `.tar.gz` distribution
+ #
+ # system 'wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz'
+ # system 'tar -xvf elasticsearch-5.1.1.tar.gz'
+ #
+ # require 'elasticsearch/extensions/test/cluster'
+ # Elasticsearch::Extensions::Test::Cluster.start command: 'elasticsearch-5.1.1/bin/elasticsearch'
#
# @see Cluster#initialize
#
@@ -161,6 +172,7 @@ module Elasticsearch
-E path.repo=/tmp \
-E repositories.url.allowed_urls=http://snapshot.test* \
-E discovery.zen.minimum_master_nodes=#{arguments[:number_of_nodes]-1} \
+ -E node.max_local_storage_nodes=#{arguments[:number_of_nodes]} \
-E logger.level=DEBUG \
#{arguments[:es_params]} \
> /dev/null
@@ -171,7 +183,7 @@ module Elasticsearch
# Create a new instance of the Cluster class
#
# @option arguments [String] :cluster_name Cluster name (default: `elasticsearch_test`)
- # @option arguments [Integer] :nodes Number of desired nodes (default: 2)
+ # @option arguments [Integer] :number_of_nodes Number of desired nodes (default: 2)
# @option arguments [String] :command Elasticsearch command (default: `elasticsearch`)
# @option arguments [String] :port Starting port number; will be auto-incremented (default: 9250)
# @option arguments [String] :node_name The node name (will be appended with a number)
@@ -188,7 +200,7 @@ module Elasticsearch
# @see Cluster#start
#
def initialize(arguments={})
- @arguments = arguments
+ @arguments = arguments.dup
@arguments[:command] ||= ENV.fetch('TEST_CLUSTER_COMMAND', 'elasticsearch')
@arguments[:port] ||= ENV.fetch('TEST_CLUSTER_PORT', 9250).to_i
@@ -221,7 +233,7 @@ module Elasticsearch
# @example Start a cluster with a custom configuration
# Elasticsearch::Extensions::Test::Cluster::Cluster.new(
# cluster_name: 'my-cluster',
- # nodes: 3,
+ # number_of_nodes: 3,
# node_name: 'my-node',
# port: 9350
# ).start
@@ -240,7 +252,7 @@ module Elasticsearch
return false
end
- __remove_cluster_data
+ __remove_cluster_data if @clear_cluster
STDOUT.print "Starting ".ansi(:faint) + arguments[:number_of_nodes].to_s.ansi(:bold, :faint) +
" Elasticsearch nodes..".ansi(:faint)
@@ -256,6 +268,7 @@ module Elasticsearch
pid = Process.spawn(command)
Process.detach pid
pids << pid
+ sleep 1
end
__check_for_running_processes(pids)
@@ -365,7 +378,7 @@ module Elasticsearch
when /^0|^1/
'0.0.0.0'
when /^2/
- '0.0.0.0'
+ '_local_'
when /^5/
'_local_'
else
@@ -425,11 +438,25 @@ module Elasticsearch
begin
# First, try the new `--version` syntax...
STDERR.puts "Running [#{arguments[:command]} --version] to determine version" if ENV['DEBUG']
- Timeout::timeout(10) { output = `#{arguments[:command]} --version` }
+ rout, wout = IO.pipe
+ pid = Process.spawn("#{arguments[:command]} --version", out: wout)
+
+ Timeout::timeout(10) do
+ Process.wait(pid)
+ wout.close unless wout.closed?
+ output = rout.read unless rout.closed?
+ rout.close unless rout.closed?
+ end
rescue Timeout::Error
- # ...else, the new `-v` syntax
+ # ...else, the old `-v` syntax
STDERR.puts "Running [#{arguments[:command]} -v] to determine version" if ENV['DEBUG']
output = `#{arguments[:command]} -v`
+ ensure
+ if pid
+ Process.kill('INT', pid) rescue Errno::ESRCH # Most likely the process has terminated already
+ end
+ wout.close unless wout.closed?
+ rout.close unless rout.closed?
end
STDERR.puts "> #{output}" if ENV['DEBUG']
@@ -485,17 +512,25 @@ module Elasticsearch
# @return Boolean
#
def __wait_for_status(status='green', timeout=30)
- Timeout::timeout(timeout) do
- loop do
- response = __get_cluster_health(status)
+ begin
+ Timeout::timeout(timeout) do
+ loop do
+ response = __get_cluster_health(status)
+ STDERR.puts response if ENV['DEBUG']
- if response && response['status'] == status && ( arguments[:number_of_nodes].nil? || arguments[:number_of_nodes].to_i == response['number_of_nodes'].to_i )
- break
- end
+ if response && response['status'] == status && ( arguments[:number_of_nodes].nil? || arguments[:number_of_nodes].to_i == response['number_of_nodes'].to_i )
+ break
+ end
- STDOUT.print '.'.ansi(:faint)
- sleep 1
+ STDOUT.print '.'.ansi(:faint)
+ sleep 1
+ end
end
+ rescue Timeout::Error => e
+ message = "\nTimeout while waiting for cluster status [#{status}]"
+ message += " and [#{arguments[:number_of_nodes]}] nodes" if arguments[:number_of_nodes]
+ STDOUT.puts message.ansi(:red, :bold)
+ raise e
end
return true
@@ -553,13 +588,12 @@ module Elasticsearch
JSON.parse(response)
end
- # Remove the data directory (unless it has been disabled by arguments)
+ # Remove the data directory
#
# @api private
#
def __remove_cluster_data
- # Wipe out data on disk for this cluster name by default
- FileUtils.rm_rf "#{arguments[:path_data]}/#{arguments[:cluster_name]}" if @clear_cluster
+ FileUtils.rm_rf arguments[:path_data]
end
diff --git a/elasticsearch-extensions/test/reindex/integration/reindex_test.rb b/elasticsearch-extensions/test/reindex/integration/reindex_test.rb
index 86bf31a..5e01c6b 100644
--- a/elasticsearch-extensions/test/reindex/integration/reindex_test.rb
+++ b/elasticsearch-extensions/test/reindex/integration/reindex_test.rb
@@ -25,13 +25,20 @@ class Elasticsearch::Extensions::ReindexIntegrationTest < Elasticsearch::Test::I
@client.index index: 'test1', type: 'd', id: 3, body: { title: 'TEST 3', category: 'three' }
@client.indices.refresh index: 'test1'
+ @client.indices.create index: 'test2'
+
@client.cluster.health wait_for_status: 'yellow'
end
+ teardown do
+ @client.indices.delete index: '_all'
+ end
+
should "copy documents from one index to another" do
reindex = Elasticsearch::Extensions::Reindex.new \
source: { index: 'test1', client: @client },
target: { index: 'test2' },
+ batch_size: 2,
refresh: true
result = reindex.perform
@@ -40,6 +47,36 @@ class Elasticsearch::Extensions::ReindexIntegrationTest < Elasticsearch::Test::I
assert_equal 3, @client.search(index: 'test2')['hits']['total']
end
+ should "copy documents with parent/child relationship" do
+ mapping = { mappings: { p: {}, c: { _parent: { type: 'p' } } } }
+ @client.indices.create index: 'test_parent_1', body: mapping
+ @client.indices.create index: 'test_parent_2', body: mapping
+
+ @client.index index: 'test_parent_1', type: 'p', id: 1, body: { title: 'Parent 1' }
+ @client.index index: 'test_parent_1', type: 'p', id: 2, body: { title: 'Parent 2' }
+ @client.index index: 'test_parent_1', type: 'c', parent: 1, body: { title: 'Child One' }
+ @client.index index: 'test_parent_1', type: 'c', parent: 1, body: { title: 'Child Two' }
+
+ @client.indices.refresh index: 'test_parent_1'
+
+ reindex = Elasticsearch::Extensions::Reindex.new \
+ source: { index: 'test_parent_1', client: @client },
+ target: { index: 'test_parent_2' },
+ batch_size: 2,
+ refresh: true
+
+ result = reindex.perform
+
+ assert_equal 0, result[:errors]
+ assert_equal 4, @client.search(index: 'test_parent_2')['hits']['total']
+
+ response = @client.search index: 'test_parent_2', body: {
+ query: { has_child: { type: 'c', query: { match: { title: 'two' } } } } }
+
+ assert_equal 1, response['hits']['hits'].size
+ assert_equal 'Parent 1', response['hits']['hits'][0]['_source']['title']
+ end
+
should "transform documents with a lambda" do
reindex = Elasticsearch::Extensions::Reindex.new \
source: { index: 'test1', client: @client },
@@ -60,18 +97,20 @@ class Elasticsearch::Extensions::ReindexIntegrationTest < Elasticsearch::Test::I
reindex = Elasticsearch::Extensions::Reindex.new \
source: { index: 'test1', client: @client },
- target: { index: 'test3', transform: lambda { |d| d['_source']['category'].upcase!; d } },
- refresh: true
+ target: { index: 'test3' }
result = reindex.perform
+ @client.indices.refresh index: 'test3'
+
assert_equal 3, result[:errors]
assert_equal 0, @client.search(index: 'test3')['hits']['total']
end
should "reindex via the API integration" do
- @client.reindex source: { index: 'test1' }, target: { index: 'test4' }
+ @client.indices.create index: 'test4'
+ @client.reindex source: { index: 'test1' }, target: { index: 'test4' }
@client.indices.refresh index: 'test4'
assert_equal 3, @client.search(index: 'test4')['hits']['total']
diff --git a/elasticsearch-extensions/test/reindex/unit/reindex_test.rb b/elasticsearch-extensions/test/reindex/unit/reindex_test.rb
index 7bf3a38..8f24a60 100644
--- a/elasticsearch-extensions/test/reindex/unit/reindex_test.rb
+++ b/elasticsearch-extensions/test/reindex/unit/reindex_test.rb
@@ -43,8 +43,8 @@ class Elasticsearch::Extensions::ReindexTest < Test::Unit::TestCase
'_id' => d['_id'],
'data' => d['_source']
} }]
- @bulk_response = {'errors'=>false, 'items' => [{'index' => {}}]}
- @bulk_response_error = {'errors'=>true, 'items' => [{'index' => {}},{'index' => {'error' => 'FOOBAR'}}]}
+ @bulk_response = {'errors'=>false, 'items' => [{'index' => {}}, {'index' => {}}]}
+ @bulk_response_error = {'errors'=>true, 'items' => [{'index' => {}}, {'index' => {'error' => 'FOOBAR'}}]}
end
should "scroll through the index and save batches in bulk" do
@@ -52,11 +52,15 @@ class Elasticsearch::Extensions::ReindexTest < Test::Unit::TestCase
subject = Elasticsearch::Extensions::Reindex.new source: { index: 'foo', client: client },
target: { index: 'bar' }
- client.expects(:search).returns({ '_scroll_id' => 'scroll_id_1' })
- client.expects(:scroll).returns(@default_response)
- .then.returns(@empty_response)
- .times(2)
- client.expects(:bulk).with(body: @bulk_request).returns(@bulk_response)
+ client.expects(:search)
+ .returns({ '_scroll_id' => 'scroll_id_1' }.merge(Marshal.load(Marshal.dump(@default_response))))
+ client.expects(:scroll)
+ .returns(Marshal.load(Marshal.dump(@default_response)))
+ .then
+ .returns(@empty_response).times(2)
+ client.expects(:bulk)
+ .with(body: @bulk_request)
+ .returns(@bulk_response).times(2)
result = subject.perform
@@ -68,10 +72,8 @@ class Elasticsearch::Extensions::ReindexTest < Test::Unit::TestCase
subject = Elasticsearch::Extensions::Reindex.new source: { index: 'foo', client: client },
target: { index: 'bar' }
- client.expects(:search).returns({ '_scroll_id' => 'scroll_id_1' })
- client.expects(:scroll).returns(@default_response)
- .then.returns(@empty_response)
- .times(2)
+ client.expects(:search).returns({ '_scroll_id' => 'scroll_id_1' }.merge(@default_response))
+ client.expects(:scroll).returns(@empty_response)
client.expects(:bulk).with(body: @bulk_request).returns(@bulk_response_error)
result = subject.perform
@@ -86,10 +88,8 @@ class Elasticsearch::Extensions::ReindexTest < Test::Unit::TestCase
target: { index: 'bar' },
transform: lambda { |d| d['_source']['foo'].upcase!; d }
- client.expects(:search).returns({ '_scroll_id' => 'scroll_id_1' })
- client.expects(:scroll).returns(@default_response)
- .then.returns(@empty_response)
- .times(2)
+ client.expects(:search).returns({ '_scroll_id' => 'scroll_id_1' }.merge(@default_response))
+ client.expects(:scroll).returns(@empty_response)
client.expects(:bulk).with do |arguments|
assert_equal 'BAR', arguments[:body][0][:index]['data']['foo']
true
diff --git a/elasticsearch-extensions/test/test/cluster/integration/cluster_test.rb b/elasticsearch-extensions/test/test/cluster/integration/cluster_test.rb
index 7d0e233..fb0f569 100644
--- a/elasticsearch-extensions/test/test/cluster/integration/cluster_test.rb
+++ b/elasticsearch-extensions/test/test/cluster/integration/cluster_test.rb
@@ -22,6 +22,11 @@ class Elasticsearch::Extensions::TestClusterIntegrationTest < Test::Unit::TestCa
should "start and stop #{build.to_s}" do
puts ("----- #{build.to_s} " + "-"*(80-7-build.to_s.size)).to_s.ansi(:bold)
Elasticsearch::Extensions::Test::Cluster.start command: PATH_TO_BUILDS.join(build.join('bin/elasticsearch')).to_s
+
+ # Index some data to create the data directory
+ client = Elasticsearch::Client.new host: "localhost:9250"
+ client.index index: 'test1', type: 'd', id: 1, body: { title: 'TEST' }
+
Elasticsearch::Extensions::Test::Cluster.stop command: PATH_TO_BUILDS.join(build.join('bin/elasticsearch')).to_s
end
end
diff --git a/elasticsearch-extensions/test/test/cluster/unit/cluster_test.rb b/elasticsearch-extensions/test/test/cluster/unit/cluster_test.rb
index bb9bf6f..23206c3 100644
--- a/elasticsearch-extensions/test/test/cluster/unit/cluster_test.rb
+++ b/elasticsearch-extensions/test/test/cluster/unit/cluster_test.rb
@@ -38,6 +38,13 @@ class Elasticsearch::Extensions::TestClusterTest < Test::Unit::TestCase
assert_equal 9400, c.arguments[:port]
end
+ should "not modify the arguments" do
+ args = { port: 9400 }.freeze
+
+ assert_nothing_raised { Cluster::Cluster.new args }
+ assert_nil args[:command]
+ end
+
should "take parameters from environment variables" do
ENV['TEST_CLUSTER_PORT'] = '9400'
@@ -88,6 +95,13 @@ class Elasticsearch::Extensions::TestClusterTest < Test::Unit::TestCase
end
end
+ should "remove cluster data" do
+ @subject.unstub(:__remove_cluster_data)
+ FileUtils.expects(:rm_rf).with("/tmp/elasticsearch_test")
+
+ @subject.__remove_cluster_data
+ end
+
context "when starting a cluster, " do
should "return false when it's already running" do
Process.expects(:spawn).never
@@ -238,11 +252,18 @@ class Elasticsearch::Extensions::TestClusterTest < Test::Unit::TestCase
assert_equal '2.0', @subject.__determine_version
end
- should "return version from `elasticsearch -v`" do
+ should "return version from `elasticsearch --version`" do
File.expects(:exist?).with('/foo/bar/bin/../lib/').returns(false)
- @subject.expects(:`)
- .with("/foo/bar/bin/elasticsearch --version")
+ Process.stubs(:wait)
+ Process.expects(:spawn)
+ .with do |command, options|
+ assert_equal "/foo/bar/bin/elasticsearch --version", command
+ end
+ .returns(123)
+ Process.expects(:kill).with('INT', 123)
+
+ IO.any_instance.expects(:read)
.returns('Version: 2.3.0-SNAPSHOT, Build: d1c86b0/2016-03-30T10:43:20Z, JVM: 1.8.0_60')
assert_equal '2.0', @subject.__determine_version
@@ -259,9 +280,15 @@ class Elasticsearch::Extensions::TestClusterTest < Test::Unit::TestCase
should "raise an exception when the version cannot be parsed from command output" do
File.expects(:exist?).with('/foo/bar/bin/../lib/').returns(false)
- @subject.expects(:`)
- .with("/foo/bar/bin/elasticsearch --version")
- .returns('Version: FOOBAR')
+ Process.stubs(:wait)
+ Process.expects(:spawn)
+ .with do |command, options|
+ assert_equal "/foo/bar/bin/elasticsearch --version", command
+ end
+ .returns(123)
+ Process.expects(:kill).with('INT', 123)
+
+ IO.any_instance.expects(:read).returns('Version: FOOBAR')
assert_raise(RuntimeError) { @subject.__determine_version }
end
diff --git a/elasticsearch-transport/Gemfile b/elasticsearch-transport/Gemfile
index 56e0bac..49be7b8 100644
--- a/elasticsearch-transport/Gemfile
+++ b/elasticsearch-transport/Gemfile
@@ -7,7 +7,7 @@ if File.exist? File.expand_path("../../elasticsearch-api/elasticsearch-api.gemsp
gem 'elasticsearch-api', :path => File.expand_path("../../elasticsearch-api", __FILE__), :require => false
end
-if File.exist? File.expand_path("../../elasticsearch-extensions", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-extensions/elasticsearch-extensions.gemspec", __FILE__)
gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => false
end
diff --git a/elasticsearch-transport/README.md b/elasticsearch-transport/README.md
index 7f8b9f8..35ce5db 100644
--- a/elasticsearch-transport/README.md
+++ b/elasticsearch-transport/README.md
@@ -16,7 +16,7 @@ data serialization and transport.
It does not handle calling the Elasticsearch API;
see the [`elasticsearch-api`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-api) library.
-The library is compatible with Ruby 1.8.7 or higher and with Elasticsearch 0.90 and 1.0.
+The library is compatible with Ruby 1.8.7 or higher and with all versions of Elasticsearch since 0.90.
Features overview:
diff --git a/elasticsearch-transport/elasticsearch-transport.gemspec b/elasticsearch-transport/elasticsearch-transport.gemspec
index d92478a..3102bde 100644
--- a/elasticsearch-transport/elasticsearch-transport.gemspec
+++ b/elasticsearch-transport/elasticsearch-transport.gemspec
@@ -58,7 +58,7 @@ Gem::Specification.new do |s|
# Prevent unit test failures on Ruby 1.8
if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
s.add_development_dependency "test-unit", '~> 2'
- s.add_development_dependency "json"
+ s.add_development_dependency "json", '~> 1.8'
end
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
diff --git a/elasticsearch-transport/lib/elasticsearch/transport/transport/base.rb b/elasticsearch-transport/lib/elasticsearch/transport/transport/base.rb
index 68b6a1f..403a90a 100644
--- a/elasticsearch-transport/lib/elasticsearch/transport/transport/base.rb
+++ b/elasticsearch-transport/lib/elasticsearch/transport/transport/base.rb
@@ -49,9 +49,9 @@ module Elasticsearch
@counter_mtx = Mutex.new
@last_request_at = Time.now
@reload_connections = options[:reload_connections]
- @reload_after = options[:reload_connections].is_a?(Fixnum) ? options[:reload_connections] : DEFAULT_RELOAD_AFTER
+ @reload_after = options[:reload_connections].is_a?(Integer) ? options[:reload_connections] : DEFAULT_RELOAD_AFTER
@resurrect_after = options[:resurrect_after] || DEFAULT_RESURRECT_AFTER
- @max_retries = options[:retry_on_failure].is_a?(Fixnum) ? options[:retry_on_failure] : DEFAULT_MAX_RETRIES
+ @max_retries = options[:retry_on_failure].is_a?(Integer) ? options[:retry_on_failure] : DEFAULT_MAX_RETRIES
@retry_on_status = Array(options[:retry_on_status]).map { |d| d.to_i }
end
@@ -244,6 +244,10 @@ module Elasticsearch
start = Time.now if logger || tracer
tries = 0
+ params = params.clone
+
+ ignore = Array(params.delete(:ignore)).compact.map { |s| s.to_i }
+
begin
tries += 1
connection = get_connection or raise Error.new("Cannot get new connection from pool.")
@@ -309,7 +313,9 @@ module Elasticsearch
__log method, path, params, body, url, response, nil, 'N/A', duration if logger
__trace method, path, params, body, url, response, nil, 'N/A', duration if tracer
__log_failed response if logger
- __raise_transport_error response
+
+ # Swallow the exception when the `ignore` parameter matches response status
+ __raise_transport_error response unless ignore.include?(response.status.to_i)
end
json = serializer.load(response.body) if response.body && !response.body.empty? && response.headers && response.headers["content-type"] =~ /json/
diff --git a/elasticsearch-transport/lib/elasticsearch/transport/transport/http/curb.rb b/elasticsearch-transport/lib/elasticsearch/transport/transport/http/curb.rb
index e66acac..c46ff64 100644
--- a/elasticsearch-transport/lib/elasticsearch/transport/transport/http/curb.rb
+++ b/elasticsearch-transport/lib/elasticsearch/transport/transport/http/curb.rb
@@ -28,12 +28,12 @@ module Elasticsearch
connection.connection.http(method.to_sym)
- headers = {}
- headers['content-type'] = 'application/json' if connection.connection.header_str =~ /\/json/
+ response_headers = {}
+ response_headers['content-type'] = 'application/json' if connection.connection.header_str =~ /\/json/
Response.new connection.connection.response_code,
connection.connection.body_str,
- headers
+ response_headers
end
end
diff --git a/elasticsearch-transport/lib/elasticsearch/transport/transport/http/faraday.rb b/elasticsearch-transport/lib/elasticsearch/transport/transport/http/faraday.rb
index 3048925..fefdf2b 100644
--- a/elasticsearch-transport/lib/elasticsearch/transport/transport/http/faraday.rb
+++ b/elasticsearch-transport/lib/elasticsearch/transport/transport/http/faraday.rb
@@ -18,11 +18,14 @@ module Elasticsearch
#
def perform_request(method, path, params={}, body=nil)
super do |connection, url|
+ headers = connection.connection.headers
+
response = connection.connection.run_request \
method.downcase.to_sym,
url,
( body ? __convert_to_json(body) : nil ),
- {}
+ headers
+
Response.new response.status, response.body, response.headers
end
end
diff --git a/elasticsearch-transport/lib/elasticsearch/transport/transport/sniffer.rb b/elasticsearch-transport/lib/elasticsearch/transport/transport/sniffer.rb
index a18709f..2d15000 100644
--- a/elasticsearch-transport/lib/elasticsearch/transport/transport/sniffer.rb
+++ b/elasticsearch-transport/lib/elasticsearch/transport/transport/sniffer.rb
@@ -5,8 +5,7 @@ module Elasticsearch
# Handles node discovery ("sniffing")
#
class Sniffer
- ES1_RE_URL = /\[([^\/]*)?\/?([^:]*):([0-9]+)\]/
- ES2_RE_URL = /([^\/]*)?\/?([^:]*):([0-9]+)/
+ PROTOCOL = 'http'
attr_reader :transport
attr_accessor :timeout
@@ -30,13 +29,18 @@ module Elasticsearch
def hosts
Timeout::timeout(timeout, SnifferTimeoutError) do
nodes = transport.perform_request('GET', '_nodes/http').body
+
hosts = nodes['nodes'].map do |id,info|
- addr_str = info["#{transport.protocol}_address"].to_s
- matches = addr_str.match(ES1_RE_URL) || addr_str.match(ES2_RE_URL)
- if matches
- host = matches[1].empty? ? matches[2] : matches[1]
- port = matches[3]
- info.merge :host => host, :port => port, :id => id
+ if info[PROTOCOL]
+ host, port = info[PROTOCOL]['publish_address'].split(':')
+
+ { :id => id,
+ :name => info['name'],
+ :version => info['version'],
+ :host => host,
+ :port => port,
+ :roles => info['roles'],
+ :attributes => info['attributes'] }
end
end.compact
diff --git a/elasticsearch-transport/lib/elasticsearch/transport/version.rb b/elasticsearch-transport/lib/elasticsearch/transport/version.rb
index b9b82e7..93660f2 100644
--- a/elasticsearch-transport/lib/elasticsearch/transport/version.rb
+++ b/elasticsearch-transport/lib/elasticsearch/transport/version.rb
@@ -1,5 +1,5 @@
module Elasticsearch
module Transport
- VERSION = "2.0.0"
+ VERSION = "5.0.1"
end
end
diff --git a/elasticsearch-transport/test/integration/client_test.rb b/elasticsearch-transport/test/integration/client_test.rb
index 4fdccfd..056f7ec 100644
--- a/elasticsearch-transport/test/integration/client_test.rb
+++ b/elasticsearch-transport/test/integration/client_test.rb
@@ -17,7 +17,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
setup do
@port = (ENV['TEST_CLUSTER_PORT'] || 9250).to_i
- system "curl -X DELETE http://localhost:#{@port}/_all > /dev/null 2>&1"
+ system "curl -X DELETE http://127.0.0.1:#{@port}/_all > /dev/null 2>&1"
@logger = Logger.new(STDERR)
@logger.formatter = proc do |severity, datetime, progname, msg|
@@ -30,7 +30,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
ANSI.ansi(severity[0] + ' ', color, :faint) + ANSI.ansi(msg, :white, :faint) + "\n"
end
- @client = Elasticsearch::Client.new host: "localhost:#{@port}"
+ @client = Elasticsearch::Client.new host: "127.0.0.1:#{@port}"
end
should "connect to the cluster" do
@@ -53,34 +53,45 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
end
end
+ should "ignore specified response codes" do
+ response = @client.perform_request 'GET', '/_foobar', ignore: 400
+ assert_equal 400, response.status
+
+ assert_instance_of Hash, response.body
+ assert_match /illegal_argument_exception/, response.body.inspect
+ end
+
should "pass options to the transport" do
@client = Elasticsearch::Client.new \
- host: "localhost:#{@port}",
+ host: "127.0.0.1:#{@port}",
logger: (ENV['QUIET'] ? nil : @logger),
- transport_options: { headers: { content_type: 'application/yaml' } }
+ transport_options: { headers: { accept: 'application/yaml', content_type: 'application/yaml' } }
response = @client.perform_request 'GET', '_cluster/health'
- assert_match /---\ncluster_name:/, response.body.to_s
+
+ assert response.body.to_s.start_with?("---\n"), "Response body should be YAML: #{response.body.inspect}"
+ assert_equal 'application/yaml', response.headers['content-type']
end
should "pass options to the Faraday::Connection with a block" do
@client = Elasticsearch::Client.new(
- host: "localhost:#{@port}",
+ host: "127.0.0.1:#{@port}",
logger: (ENV['QUIET'] ? nil : @logger)
) do |client|
- client.headers['Content-Type'] = 'application/yaml'
+ client.headers['Content-Type'] = 'application/yaml' # For ES 2.x
+ client.headers['Accept'] = 'application/yaml' # For ES 5.x
end
response = @client.perform_request 'GET', '_cluster/health'
- assert response.body.start_with?("---\n"), "Response body should be YAML: #{response.body.inspect}"
+ assert response.body.to_s.start_with?("---\n"), "Response body should be YAML: #{response.body.inspect}"
assert_equal 'application/yaml', response.headers['content-type']
end
context "with round robin selector" do
setup do
@client = Elasticsearch::Client.new \
- hosts: ["localhost:#{@port}", "localhost:#{@port+1}" ],
+ hosts: ["127.0.0.1:#{@port}", "127.0.0.1:#{@port+1}" ],
logger: (ENV['QUIET'] ? nil : @logger)
end
@@ -103,7 +114,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
setup do
@port = (ENV['TEST_CLUSTER_PORT'] || 9250).to_i
@client = Elasticsearch::Client.new \
- hosts: ["localhost:#{@port}", "foobar1"],
+ hosts: ["127.0.0.1:#{@port}", "foobar1"],
logger: (ENV['QUIET'] ? nil : @logger),
retry_on_failure: true
end
@@ -116,7 +127,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
should "raise exception when it cannot get any healthy server" do
@client = Elasticsearch::Client.new \
- hosts: ["localhost:#{@port}", "foobar1", "foobar2", "foobar3"],
+ hosts: ["127.0.0.1:#{@port}", "foobar1", "foobar2", "foobar3"],
logger: (ENV['QUIET'] ? nil : @logger),
retry_on_failure: 1
@@ -135,7 +146,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
context "with a sick node and reloading on failure" do
setup do
@client = Elasticsearch::Client.new \
- hosts: ["localhost:#{@port}", "foobar1", "foobar2"],
+ hosts: ["127.0.0.1:#{@port}", "foobar1", "foobar2"],
logger: (ENV['QUIET'] ? nil : @logger),
reload_on_failure: true
end
@@ -152,7 +163,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
context "with retrying on status" do
should "retry when the status does match" do
@client = Elasticsearch::Client.new \
- hosts: ["localhost:#{@port}"],
+ hosts: ["127.0.0.1:#{@port}"],
logger: (ENV['QUIET'] ? nil : @logger),
retry_on_status: 400
@@ -170,7 +181,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
context "when reloading connections" do
should "keep existing connections" do
require 'patron' # We need a client with keep-alive
- client = Elasticsearch::Transport::Client.new host: "localhost:#{@port}", adapter: :patron, logger: @logger
+ client = Elasticsearch::Transport::Client.new host: "127.0.0.1:#{@port}", adapter: :patron, logger: @logger
assert_equal 'Faraday::Adapter::Patron',
client.transport.connections.first.connection.builder.handlers.first.name
@@ -192,7 +203,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
should "set the adapter with a block" do
require 'net/http/persistent'
- client = Elasticsearch::Transport::Client.new url: "localhost:#{@port}" do |f|
+ client = Elasticsearch::Transport::Client.new url: "127.0.0.1:#{@port}" do |f|
f.adapter :net_http_persistent
end
@@ -207,7 +218,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
teardown { begin; Object.send(:remove_const, :Patron); rescue NameError; end }
require 'patron'
- client = Elasticsearch::Transport::Client.new host: "localhost:#{@port}"
+ client = Elasticsearch::Transport::Client.new host: "127.0.0.1:#{@port}"
assert_equal 'Faraday::Adapter::Patron',
client.transport.connections.first.connection.builder.handlers.first.name
diff --git a/elasticsearch-transport/test/unit/sniffer_test.rb b/elasticsearch-transport/test/unit/sniffer_test.rb
index f1ab346..ed9f89b 100644
--- a/elasticsearch-transport/test/unit/sniffer_test.rb
+++ b/elasticsearch-transport/test/unit/sniffer_test.rb
@@ -11,6 +11,38 @@ class Elasticsearch::Transport::Transport::SnifferTest < Test::Unit::TestCase
Elasticsearch::Transport::Transport::Response.new 200, MultiJson.load(json)
end
+ DEFAULT_NODES_INFO_RESPONSE = <<-JSON
+ {
+ "cluster_name" : "elasticsearch_test",
+ "nodes" : {
+ "N1" : {
+ "name" : "Node 1",
+ "transport_address" : "127.0.0.1:9300",
+ "host" : "testhost1",
+ "ip" : "127.0.0.1",
+ "version" : "5.0.0",
+ "roles": [
+ "master",
+ "data",
+ "ingest"
+ ],
+ "attributes": {
+ "testattr": "test"
+ },
+ "http": {
+ "bound_address": [
+ "[fe80::1]:9250",
+ "[::1]:9250",
+ "127.0.0.1:9250"
+ ],
+ "publish_address": "127.0.0.1:9250",
+ "max_content_length_in_bytes": 104857600
+ }
+ }
+ }
+ }
+ JSON
+
context "Sniffer" do
setup do
@transport = DummyTransport.new
@@ -21,47 +53,25 @@ class Elasticsearch::Transport::Transport::SnifferTest < Test::Unit::TestCase
assert_equal @transport, @sniffer.transport
end
- should "return an array of hosts as hashes with Elasticsearch 1.x syntax" do
- @transport.expects(:perform_request).returns __nodes_info <<-JSON
- {
- "ok" : true,
- "cluster_name" : "elasticsearch_test",
- "nodes" : {
- "N1" : {
- "name" : "Node 1",
- "transport_address" : "inet[/192.168.1.23:9300]",
- "hostname" : "testhost1",
- "version" : "0.20.6",
- "http_address" : "inet[/192.168.1.23:9200]",
- "thrift_address" : "/192.168.1.23:9500",
- "memcached_address" : "inet[/192.168.1.23:11211]"
- }
- }
- }
- JSON
+ should "return an array of hosts as hashes" do
+ @transport.expects(:perform_request).returns __nodes_info(DEFAULT_NODES_INFO_RESPONSE)
hosts = @sniffer.hosts
assert_equal 1, hosts.size
- assert_equal '192.168.1.23', hosts.first[:host]
- assert_equal '9200', hosts.first[:port]
- assert_equal 'Node 1', hosts.first['name']
+ assert_equal '127.0.0.1', hosts.first[:host]
+ assert_equal '9250', hosts.first[:port]
+ assert_equal 'Node 1', hosts.first[:name]
end
- should "return an array of hosts as hashes with Elasticsearch 2.0 syntax" do
+ should "return an array of hosts as hostnames when a hostname is returned" do
@transport.expects(:perform_request).returns __nodes_info <<-JSON
{
- "ok" : true,
- "cluster_name" : "elasticsearch_test",
"nodes" : {
"N1" : {
- "name" : "Node 1",
- "transport_address" : "192.168.1.23:9300",
- "hostname" : "testhost1",
- "version" : "0.20.6",
- "http_address" : "192.168.1.23:9200",
- "thrift_address" : "192.168.1.23:9500",
- "memcached_address" : "192.168.1.23:11211"
+ "http": {
+ "publish_address": "testhost1.com:9250"
+ }
}
}
}
@@ -70,66 +80,36 @@ class Elasticsearch::Transport::Transport::SnifferTest < Test::Unit::TestCase
hosts = @sniffer.hosts
assert_equal 1, hosts.size
- assert_equal '192.168.1.23', hosts.first[:host]
- assert_equal '9200', hosts.first[:port]
- assert_equal 'Node 1', hosts.first['name']
+ assert_equal 'testhost1.com', hosts.first[:host]
+ assert_equal '9250', hosts.first[:port]
end
- should "return an array of hosts as hostnames when a hostname is returned" do
- @transport.expects(:perform_request).returns __nodes_info <<-JSON
- {
- "ok" : true,
- "cluster_name" : "elasticsearch_test",
- "nodes" : {
- "N1" : {
- "name" : "Node 1",
- "transport_address" : "inet[/192.168.1.23:9300]",
- "hostname" : "testhost1",
- "version" : "0.20.6",
- "http_address" : "inet[testhost1.com/192.168.1.23:9200]",
- "thrift_address" : "/192.168.1.23:9500",
- "memcached_address" : "inet[/192.168.1.23:11211]"
- }
- }
- }
- JSON
+ should "return HTTP hosts for the HTTPS protocol in the transport" do
+ @transport = DummyTransport.new :options => { :protocol => 'https' }
+ @sniffer = Elasticsearch::Transport::Transport::Sniffer.new @transport
- hosts = @sniffer.hosts
+ @transport.expects(:perform_request).returns __nodes_info(DEFAULT_NODES_INFO_RESPONSE)
- assert_equal 1, hosts.size
- assert_equal 'testhost1.com', hosts.first[:host]
- assert_equal '9200', hosts.first[:port]
- assert_equal 'Node 1', hosts.first['name']
+ assert_equal 1, @sniffer.hosts.size
end
should "skip hosts without a matching transport protocol" do
- @transport = DummyTransport.new :options => { :protocol => 'memcached' }
+ @transport = DummyTransport.new
@sniffer = Elasticsearch::Transport::Transport::Sniffer.new @transport
@transport.expects(:perform_request).returns __nodes_info <<-JSON
{
- "ok" : true,
- "cluster_name" : "elasticsearch_test",
"nodes" : {
"N1" : {
- "name" : "Memcached Node",
- "http_address" : "inet[/192.168.1.23:9200]",
- "memcached_address" : "inet[/192.168.1.23:11211]"
- },
- "N2" : {
- "name" : "HTTP Node",
- "http_address" : "inet[/192.168.1.23:9200]"
+ "foobar": {
+ "publish_address": "foobar:1234"
+ }
}
}
}
JSON
- hosts = @sniffer.hosts
-
- assert_equal 1, hosts.size
- assert_equal '192.168.1.23', hosts.first[:host]
- assert_equal '11211', hosts.first[:port]
- assert_equal 'Memcached Node', hosts.first['name']
+ assert_empty @sniffer.hosts
end
should "have configurable timeout" do
diff --git a/elasticsearch-transport/test/unit/transport_base_test.rb b/elasticsearch-transport/test/unit/transport_base_test.rb
index 7ff970a..773fff4 100644
--- a/elasticsearch-transport/test/unit/transport_base_test.rb
+++ b/elasticsearch-transport/test/unit/transport_base_test.rb
@@ -246,6 +246,21 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
end
end
+ should "not raise an error when the :ignore argument has been passed" do
+ @transport.stubs(:get_connection).returns(stub_everything :failures => 1)
+
+ assert_raise Elasticsearch::Transport::Transport::Errors::BadRequest do
+ @transport.perform_request 'GET', '/' do
+ Elasticsearch::Transport::Transport::Response.new 400, 'CLIENT ERROR'
+ end
+ end
+
+ # No `BadRequest` error
+ @transport.perform_request 'GET', '/', :ignore => 400 do
+ Elasticsearch::Transport::Transport::Response.new 400, 'CLIENT ERROR'
+ end
+ end
+
should "mark the connection as dead on failure" do
c = stub_everything :failures => 1
@transport.expects(:get_connection).returns(c)
diff --git a/elasticsearch-transport/test/unit/transport_curb_test.rb b/elasticsearch-transport/test/unit/transport_curb_test.rb
index 85a3aea..06d8c9a 100644
--- a/elasticsearch-transport/test/unit/transport_curb_test.rb
+++ b/elasticsearch-transport/test/unit/transport_curb_test.rb
@@ -55,7 +55,7 @@ else
@transport.perform_request 'POST', '/', {}, '{"foo":"bar"}'
end
- should "set application/json header" do
+ should "set application/json response header" do
@transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
@transport.connections.first.connection.expects(:body_str).returns('{"foo":"bar"}')
@transport.connections.first.connection.expects(:header_str).returns('HTTP/1.1 200 OK\r\nContent-Type: application/json; charset=UTF-8\r\nContent-Length: 311\r\n\r\n')
diff --git a/elasticsearch-transport/test/unit/transport_faraday_test.rb b/elasticsearch-transport/test/unit/transport_faraday_test.rb
index b6567b9..41ae3a8 100644
--- a/elasticsearch-transport/test/unit/transport_faraday_test.rb
+++ b/elasticsearch-transport/test/unit/transport_faraday_test.rb
@@ -33,8 +33,12 @@ class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestC
should "properly prepare the request" do
@transport.connections.first.connection.expects(:run_request).with do |method, url, body, headers|
- :post == method && '{"foo":"bar"}' == body
+ assert_equal :post, method
+ assert_equal '{"foo":"bar"}', body
+ assert_nil headers['Accept']
+ true
end.returns(stub_everything)
+
@transport.perform_request 'POST', '/', {}, {:foo => 'bar'}
end
diff --git a/elasticsearch/Gemfile b/elasticsearch/Gemfile
index 902e608..ba3d89d 100644
--- a/elasticsearch/Gemfile
+++ b/elasticsearch/Gemfile
@@ -3,14 +3,14 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in elasticsearch.gemspec
gemspec
-if File.exists? File.expand_path("../../elasticsearch-api/elasticsearch-api.gemspec", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-api/elasticsearch-api.gemspec", __FILE__)
gem 'elasticsearch-api', :path => File.expand_path("../../elasticsearch-api", __FILE__), :require => false
end
-if File.exists? File.expand_path("../../elasticsearch-transport/elasticsearch-transport.gemspec", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-transport/elasticsearch-transport.gemspec", __FILE__)
gem 'elasticsearch-transport', :path => File.expand_path("../../elasticsearch-transport", __FILE__), :require => false
end
-if File.exists? File.expand_path("../../elasticsearch-extensions", __FILE__)
+if File.exist? File.expand_path("../../elasticsearch-extensions", __FILE__)
gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => true
end
diff --git a/elasticsearch/README.md b/elasticsearch/README.md
index 8a75d78..9a25279 100644
--- a/elasticsearch/README.md
+++ b/elasticsearch/README.md
@@ -19,14 +19,17 @@ see the <https://github.com/elasticsearch/elasticsearch-rails> project.)
## Compatibility
-The library is compatible with Ruby 1.8.7 and higher.
+The Elasticsearch client for Ruby is compatible with Ruby 1.8.7 and higher.
-The library is compatible with Elasticsearch 0.90 and 1.0 -- you have to install and use a matching version, though.
+The client's API is compatible with Elasticsearch's API versions from 0.90 till current,
+just use a release matching major version of Elasticsearch.
-The 1.x versions and the master branch are compatible with **Elasticsearch 1.0** API.
-
-To use the **Elasticsearch 0.90** API, install the **0.4.x** gem version or use the corresponding
-[`0.4`](https://github.com/elasticsearch/elasticsearch-ruby/tree/0.4) branch.
+| Ruby | | Elasticsearch |
+|:-------------:|:-:| :-----------: |
+| 0.90 | → | 0.90 |
+| 1.x | → | 1.x |
+| 2.x | → | 2.x |
+| master | → | master |
## Installation
diff --git a/elasticsearch/elasticsearch.gemspec b/elasticsearch/elasticsearch.gemspec
index 8796896..e93c928 100644
--- a/elasticsearch/elasticsearch.gemspec
+++ b/elasticsearch/elasticsearch.gemspec
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = [ "README.md", "LICENSE.txt" ]
s.rdoc_options = [ "--charset=UTF-8" ]
- s.add_dependency "elasticsearch-transport", '2.0.0'
- s.add_dependency "elasticsearch-api", '2.0.0'
+ s.add_dependency "elasticsearch-transport", '5.0.1'
+ s.add_dependency "elasticsearch-api", '5.0.1'
s.add_development_dependency "bundler", "> 1"
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
# Prevent unit test failures on Ruby 1.8
if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
s.add_development_dependency "test-unit", '~> 2'
- s.add_development_dependency "json"
+ s.add_development_dependency "json", '~> 1.8'
end
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
diff --git a/elasticsearch/lib/elasticsearch/version.rb b/elasticsearch/lib/elasticsearch/version.rb
index 9f7944e..a9c0d99 100644
--- a/elasticsearch/lib/elasticsearch/version.rb
+++ b/elasticsearch/lib/elasticsearch/version.rb
@@ -1,3 +1,3 @@
module Elasticsearch
- VERSION = "2.0.0"
+ VERSION = "5.0.1"
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-elasticsearch.git
More information about the Pkg-ruby-extras-commits
mailing list