elasticsearch-api 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGU5ZjdkZWQ4MmQ3NDhiMzhmY2VjYjE4ZTk3N2NhNDkwMGJhOGMzMw==
4
+ N2IwM2IzMzU4M2YzNWEzNzk3NTJmNmEwMjBlN2QxMzQ0OGY2NjMxNw==
5
5
  data.tar.gz: !binary |-
6
- NWRmOGJjYTZlZDY3Zjk5ZWQ0NmFlOTI1M2NjNzczMzY2NDRkNWI3Yw==
6
+ NjYxZDkwNTBlN2Q5MDIwYjVmNWY2YWQzYjIyMDJmZDgwZTc1N2Y4MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDc5ZDcxNzhiNjJjNzcwNWQyZjEwMmFmMWY1NzA3OWUyNWVlNGYyNjRmMGEz
10
- MGI5ZTQwZTI2OGJmNGJlNzQzZTY0ZTdjNTM0ZWU4MzI4NTJjNzkzOTA3N2My
11
- YjI5MzAxMTlhOTg1OGFiMTZlZGU1Mzk5MDQ2MWRmMTI3YmFjOGU=
9
+ N2Q2MzJhNDllNjkzZmZlNjRjNzZkZDk1YTVkOTg4MDg1MjdmOGU2NzI1ODNl
10
+ ZDBkMWYzMjc1NDgxYWU3NGNlYTM0YmE1NmJiZDdjMDRkNDE2ZTM3ODA1NTkx
11
+ ZGMxZmY3NzZmNDU3MmU5MGI5MDYzMzc4MDAyMmFhOWI5YWNhYTY=
12
12
  data.tar.gz: !binary |-
13
- YzZjODYyMWU1YTgxMmEwYTc3NDdjMjA3YWMyOGUyOGM0ZDE3ZDZjNTdiNmZh
14
- OWM4NjA4MTE4ZmU5ZDdiMmUyYzY4NzBhMzlmMjRiYzExMTc4YTQ0MDNiYWRj
15
- OGE4ZWZjNGMwNjY0YzYwMDI1OTFiZDAzNWU5NmNmZjUzYzgxZTk=
13
+ NzM3MTNhNjY4YWE2YTM4OWI5ZDM4NGM4YTFjYzdhNjQ5MzM4OTFmZDZiNGQ2
14
+ MTU1N2U4OGJmNWVjNDI4ODNiN2VjNjE0NzIwMTVmYzgxYjc2OWMwYWQ0MjE1
15
+ ZWRiNmVjYzU4ZDc0MTQ1YTdmYzQ3ZTYyODY5MWE1ZTQyZDA2ZjU=
data/README.md CHANGED
@@ -16,7 +16,7 @@ The library is compatible with Ruby 1.8.7 or higher.
16
16
 
17
17
  The library is compatible with Elasticsearch 0.90 and 1.0 -- you have to install and use a matching version, though.
18
18
 
19
- The 1.x versions and the master branch are compatible with **Elasticsearch 1.0** API.
19
+ The 1.x versions and the master branch are compatible with **Elasticsearch 1.x** API.
20
20
 
21
21
  To use the **Elasticsearch 0.90** API, install the **0.4.x** gem version or use the corresponding
22
22
  [`0.4`](https://github.com/elasticsearch/elasticsearch-ruby/tree/0.4) branch.
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
39
39
  s.add_development_dependency "turn"
40
40
  s.add_development_dependency "yard"
41
41
  s.add_development_dependency "pry"
42
- s.add_development_dependency "ci_reporter"
42
+ s.add_development_dependency "ci_reporter", "~> 1.9"
43
43
 
44
44
  # Gems for testing integrations
45
45
  s.add_development_dependency "jsonify"
@@ -60,7 +60,6 @@ Gem::Specification.new do |s|
60
60
  s.add_development_dependency "simplecov-rcov"
61
61
  s.add_development_dependency "cane"
62
62
  s.add_development_dependency "require-prof" unless defined?(JRUBY_VERSION) || defined?(Rubinius)
63
- s.add_development_dependency "coveralls"
64
63
  end
65
64
 
66
65
  s.description = <<-DESC.gsub(/^ /, '')
@@ -0,0 +1,24 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Actions
4
+
5
+ # Remove an indexed script from Elasticsearch
6
+ #
7
+ # @option arguments [String] :id Script ID (*Required*)
8
+ # @option arguments [String] :lang Script language (*Required*)
9
+ #
10
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-scripting.html
11
+ #
12
+ def delete_script(arguments={})
13
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
14
+ raise ArgumentError, "Required argument 'lang' missing" unless arguments[:lang]
15
+ method = 'DELETE'
16
+ path = "_scripts/#{arguments[:lang]}/#{arguments[:id]}"
17
+ params = {}
18
+ body = nil
19
+
20
+ perform_request(method, path, params, body).body
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Actions
4
+
5
+ # Retrieve an indexed template from Elasticsearch
6
+ #
7
+ # @option arguments [String] :id Template ID
8
+ #
9
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html
10
+ #
11
+ def delete_template(arguments={})
12
+ method = 'DELETE'
13
+ path = "_search/template/#{arguments[:id]}"
14
+ params = {}
15
+ body = nil
16
+
17
+ perform_request(method, path, params, body).body
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Actions
4
+
5
+ # Retrieve an indexed script from Elasticsearch
6
+ #
7
+ # @option arguments [String] :id Script ID (*Required*)
8
+ # @option arguments [String] :lang Script language (*Required*)
9
+ #
10
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-scripting.html#_indexed_scripts
11
+ #
12
+ def get_script(arguments={})
13
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
14
+ raise ArgumentError, "Required argument 'lang' missing" unless arguments[:lang]
15
+ method = 'GET'
16
+ path = "_scripts/#{arguments[:lang]}/#{arguments[:id]}"
17
+ params = {}
18
+ body = nil
19
+
20
+ perform_request(method, path, params, body).body
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Actions
4
+
5
+ # Retrieve an indexed script from Elasticsearch
6
+ #
7
+ # @option arguments [String] :id Template ID (*Required*)
8
+ # @option arguments [Hash] :body The document
9
+ #
10
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html
11
+ #
12
+ def get_template(arguments={})
13
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
14
+ method = 'GET'
15
+ path = "_search/template/#{arguments[:id]}"
16
+ params = {}
17
+ body = arguments[:body]
18
+
19
+ perform_request(method, path, params, body).body
20
+ end
21
+ end
22
+ end
23
+ end
@@ -21,11 +21,10 @@ module Elasticsearch
21
21
  #
22
22
  # @example Delete all indices
23
23
  #
24
- # client.indices.delete
25
24
  # client.indices.delete index: '_all'
26
25
  #
27
26
  # @option arguments [List] :index A comma-separated list of indices to delete;
28
- # use `_all` or leave empty to delete all indices
27
+ # use `_all` to delete all indices
29
28
  # @option arguments [Time] :timeout Explicit operation timeout
30
29
  #
31
30
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-index/
@@ -16,14 +16,20 @@ module Elasticsearch
16
16
  # @note Use the {Cluster::Actions#state} API to get a list of all templates.
17
17
  #
18
18
  # @option arguments [String] :name The name of the template (supports wildcards)
19
+ # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
20
+ # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
21
+ # (default: false)
19
22
  #
20
23
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/
21
24
  #
22
25
  def get_template(arguments={})
26
+ valid_params = [ :flat_settings, :local ]
27
+
23
28
  method = 'GET'
24
29
  path = Utils.__pathify '_template', Utils.__escape(arguments[:name])
25
- params = {}
26
- body = nil
30
+
31
+ params = Utils.__validate_and_extract_params arguments, valid_params
32
+ body = arguments[:body]
27
33
 
28
34
  perform_request(method, path, params, body).body
29
35
  end
@@ -0,0 +1,43 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Actions
4
+
5
+ # Store a script in an internal index (`.scripts`), to be able to reference them
6
+ # in search definitions (with dynamic scripting disabled)
7
+ #
8
+ # @example Storing an Mvel script in Elasticsearch and using it in function score
9
+ #
10
+ # client.put_script lang: 'groovy', id: 'my_score', body: { script: 'log(_score * factor)' }
11
+ #
12
+ # client.search body: {
13
+ # query: {
14
+ # function_score: {
15
+ # query: { match: { title: 'foo' } },
16
+ # functions: [ { script_score: { script_id: 'my_score', params: { factor: 3 } } } ]
17
+ # }
18
+ # }
19
+ # }
20
+ #
21
+ # @option arguments [String] :id Script ID (*Required*)
22
+ # @option arguments [String] :lang Script language (*Required*)
23
+ # @option arguments [Hash] :body A JSON document containing the script (*Required*)
24
+ #
25
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-scripting.html#_indexed_scripts
26
+ #
27
+ def put_script(arguments={})
28
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
29
+ raise ArgumentError, "Required argument 'lang' missing" unless arguments[:lang]
30
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
31
+
32
+ method = 'PUT'
33
+ path = "_scripts/#{arguments[:lang]}/#{arguments[:id]}"
34
+
35
+ params = {}
36
+
37
+ body = arguments[:body]
38
+
39
+ perform_request(method, path, params, body).body
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Actions
4
+
5
+ # Store a template for the search definition in Elasticsearch,
6
+ # to be later used with the `search_template` method
7
+ #
8
+ # @option arguments [String] :id Template ID (*Required*)
9
+ # @option arguments [Hash] :body The document (*Required*)
10
+ #
11
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html
12
+ #
13
+ def put_template(arguments={})
14
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
15
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
16
+ method = 'PUT'
17
+ path = "_search/template/#{arguments[:id]}"
18
+ params = {}
19
+ body = arguments[:body]
20
+
21
+ perform_request(method, path, params, body).body
22
+ end
23
+ end
24
+ end
25
+ end
@@ -22,6 +22,15 @@ module Elasticsearch
22
22
  # facets: { tags: { terms: { field: 'tags' } } }
23
23
  # }
24
24
  #
25
+ # @example Paginating results: return 10 documents, beginning from the 10th
26
+ #
27
+ # client.search index: 'myindex',
28
+ # body: {
29
+ # query: { match: { title: 'test' } },
30
+ # from: 10,
31
+ # size: 10
32
+ # }
33
+ #
25
34
  # @example Passing the search definition as a `String`, built with a JSON builder
26
35
  #
27
36
  # require 'jbuilder'
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module API
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class DeleteScriptTest < ::Test::Unit::TestCase
6
+
7
+ context "Delete script" do
8
+ subject { FakeClient.new }
9
+
10
+ should "perform correct request" do
11
+ subject.expects(:perform_request).with do |method, url, params, body|
12
+ assert_equal 'DELETE', method
13
+ assert_equal '_scripts/groovy/foo', url
14
+ assert_equal Hash.new, params
15
+ assert_nil body
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.delete_script :lang => "groovy", :id => "foo"
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class DeleteTemplateTest < ::Test::Unit::TestCase
6
+
7
+ context "Delete template" do
8
+ subject { FakeClient.new }
9
+
10
+ should "perform correct request" do
11
+ subject.expects(:perform_request).with do |method, url, params, body|
12
+ assert_equal 'DELETE', method
13
+ assert_equal '_search/template/foo', url
14
+ assert_equal Hash.new, params
15
+ assert_nil body
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.delete_template :id => "foo"
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class GetScriptTest < ::Test::Unit::TestCase
6
+
7
+ context "Get script" do
8
+ subject { FakeClient.new }
9
+
10
+ should "perform correct request" do
11
+ subject.expects(:perform_request).with do |method, url, params, body|
12
+ assert_equal 'GET', method
13
+ assert_equal '_scripts/groovy/foo', url
14
+ assert_equal Hash.new, params
15
+ assert_nil body
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.get_script :lang => "groovy", :id => 'foo'
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class GetTemplateTest < ::Test::Unit::TestCase
6
+
7
+ context "Get template" do
8
+ subject { FakeClient.new }
9
+
10
+ should "perform correct request" do
11
+ subject.expects(:perform_request).with do |method, url, params, body|
12
+ assert_equal 'GET', method
13
+ assert_equal '_search/template/foo', url
14
+ assert_equal Hash.new, params
15
+ assert_nil body
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.get_template :id => "foo"
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class PutScriptTest < ::Test::Unit::TestCase
6
+
7
+ context "Put script" do
8
+ subject { FakeClient.new }
9
+
10
+ should "perform correct request" do
11
+ subject.expects(:perform_request).with do |method, url, params, body|
12
+ assert_equal 'PUT', method
13
+ assert_equal '_scripts/groovy/foo', url
14
+ assert_equal Hash.new, params
15
+ assert_equal 'bar', body[:script]
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.put_script :lang => 'groovy', :id => 'foo', :body => { :script => 'bar' }
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class PutTemplateTest < ::Test::Unit::TestCase
6
+
7
+ context "Put template" do
8
+ subject { FakeClient.new }
9
+
10
+ should "perform correct request" do
11
+ subject.expects(:perform_request).with do |method, url, params, body|
12
+ assert_equal 'PUT', method
13
+ assert_equal '_search/template/foo', url
14
+ assert_equal Hash.new, params
15
+ assert_equal Hash.new, body
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.put_template :id => 'foo', :body => {}
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -196,16 +196,16 @@ dependencies:
196
196
  name: ci_reporter
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ! '>='
199
+ - - ~>
200
200
  - !ruby/object:Gem::Version
201
- version: '0'
201
+ version: '1.9'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ! '>='
206
+ - - ~>
207
207
  - !ruby/object:Gem::Version
208
- version: '0'
208
+ version: '1.9'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: jsonify
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -332,20 +332,6 @@ dependencies:
332
332
  - - ! '>='
333
333
  - !ruby/object:Gem::Version
334
334
  version: '0'
335
- - !ruby/object:Gem::Dependency
336
- name: coveralls
337
- requirement: !ruby/object:Gem::Requirement
338
- requirements:
339
- - - ! '>='
340
- - !ruby/object:Gem::Version
341
- version: '0'
342
- type: :development
343
- prerelease: false
344
- version_requirements: !ruby/object:Gem::Requirement
345
- requirements:
346
- - - ! '>='
347
- - !ruby/object:Gem::Version
348
- version: '0'
349
335
  description: ! 'Ruby API for Elasticsearch. See the `elasticsearch` gem for full integration.
350
336
 
351
337
  '
@@ -393,10 +379,14 @@ files:
393
379
  - lib/elasticsearch/api/actions/create.rb
394
380
  - lib/elasticsearch/api/actions/delete.rb
395
381
  - lib/elasticsearch/api/actions/delete_by_query.rb
382
+ - lib/elasticsearch/api/actions/delete_script.rb
383
+ - lib/elasticsearch/api/actions/delete_template.rb
396
384
  - lib/elasticsearch/api/actions/exists.rb
397
385
  - lib/elasticsearch/api/actions/explain.rb
398
386
  - lib/elasticsearch/api/actions/get.rb
387
+ - lib/elasticsearch/api/actions/get_script.rb
399
388
  - lib/elasticsearch/api/actions/get_source.rb
389
+ - lib/elasticsearch/api/actions/get_template.rb
400
390
  - lib/elasticsearch/api/actions/index.rb
401
391
  - lib/elasticsearch/api/actions/indices/analyze.rb
402
392
  - lib/elasticsearch/api/actions/indices/clear_cache.rb
@@ -447,6 +437,8 @@ files:
447
437
  - lib/elasticsearch/api/actions/nodes/stats.rb
448
438
  - lib/elasticsearch/api/actions/percolate.rb
449
439
  - lib/elasticsearch/api/actions/ping.rb
440
+ - lib/elasticsearch/api/actions/put_script.rb
441
+ - lib/elasticsearch/api/actions/put_template.rb
450
442
  - lib/elasticsearch/api/actions/scroll.rb
451
443
  - lib/elasticsearch/api/actions/search.rb
452
444
  - lib/elasticsearch/api/actions/search_shards.rb
@@ -501,10 +493,14 @@ files:
501
493
  - test/unit/create_document_test.rb
502
494
  - test/unit/delete_by_query_test.rb
503
495
  - test/unit/delete_document_test.rb
496
+ - test/unit/delete_script_test.rb
497
+ - test/unit/delete_template_test.rb
504
498
  - test/unit/exists_document_test.rb
505
499
  - test/unit/explain_document_test.rb
506
500
  - test/unit/get_document_source_test.rb
507
501
  - test/unit/get_document_test.rb
502
+ - test/unit/get_script_test.rb
503
+ - test/unit/get_template_test.rb
508
504
  - test/unit/hashie_test.rb
509
505
  - test/unit/index_document_test.rb
510
506
  - test/unit/indices/analyze_test.rb
@@ -557,6 +553,8 @@ files:
557
553
  - test/unit/nodes/stats_test.rb
558
554
  - test/unit/percolate_test.rb
559
555
  - test/unit/ping_test.rb
556
+ - test/unit/put_script_test.rb
557
+ - test/unit/put_template_test.rb
560
558
  - test/unit/scroll_test.rb
561
559
  - test/unit/search_shards_test.rb
562
560
  - test/unit/search_template_test.rb
@@ -630,10 +628,14 @@ test_files:
630
628
  - test/unit/create_document_test.rb
631
629
  - test/unit/delete_by_query_test.rb
632
630
  - test/unit/delete_document_test.rb
631
+ - test/unit/delete_script_test.rb
632
+ - test/unit/delete_template_test.rb
633
633
  - test/unit/exists_document_test.rb
634
634
  - test/unit/explain_document_test.rb
635
635
  - test/unit/get_document_source_test.rb
636
636
  - test/unit/get_document_test.rb
637
+ - test/unit/get_script_test.rb
638
+ - test/unit/get_template_test.rb
637
639
  - test/unit/hashie_test.rb
638
640
  - test/unit/index_document_test.rb
639
641
  - test/unit/indices/analyze_test.rb
@@ -686,6 +688,8 @@ test_files:
686
688
  - test/unit/nodes/stats_test.rb
687
689
  - test/unit/percolate_test.rb
688
690
  - test/unit/ping_test.rb
691
+ - test/unit/put_script_test.rb
692
+ - test/unit/put_template_test.rb
689
693
  - test/unit/scroll_test.rb
690
694
  - test/unit/search_shards_test.rb
691
695
  - test/unit/search_template_test.rb