es-elasticity 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c5f0cdc13a933f514fc74015c2dc23b8733f8a0
|
4
|
+
data.tar.gz: f345594a1b7770bfc40ad274e947b3db3b3b5ffd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22d071dd3e4166f747022a8fb0202edbd468e108874a310408f98227738b99201f37e167208d6c663ce61913a502ceda3d4f4165c1cbb874b8c57da28556b676
|
7
|
+
data.tar.gz: b32c8f0fdfc9d27822f13125f18fc71248b3d41b3e5dd73c0465603fabf63eacac6844d6c4cd93b0838c7503f1b3b34dcf35ab8b0344e036cac5ac8a1bb1e478
|
@@ -1,11 +1,14 @@
|
|
1
1
|
module Elasticity
|
2
2
|
class InstrumentedClient
|
3
|
+
INDICES_METHODS = %w(exists create delete get_settings get_mapping flush get_alias get_aliases put_alias delete_alias exists_alias update_aliases)
|
4
|
+
INDEX_METHODS = %w(index delete get mget search count msearch scroll delete_by_query bulk)
|
5
|
+
|
3
6
|
def initialize(client)
|
4
7
|
@client = client
|
5
8
|
end
|
6
9
|
|
7
10
|
# Generate wrapper methods for @client.indices
|
8
|
-
|
11
|
+
INDICES_METHODS.each do |method_name|
|
9
12
|
full_name = "index_#{method_name}"
|
10
13
|
|
11
14
|
define_method(full_name) do |*args, &block|
|
@@ -16,7 +19,7 @@ module Elasticity
|
|
16
19
|
end
|
17
20
|
|
18
21
|
# Generate wrapper methods for @client
|
19
|
-
|
22
|
+
INDEX_METHODS.each do |method_name|
|
20
23
|
define_method(method_name) do |*args, &block|
|
21
24
|
instrument(method_name, args) do
|
22
25
|
@client.public_send(method_name, *args, &block)
|
@@ -5,13 +5,13 @@ module Elasticity
|
|
5
5
|
GRAY = "\e[90m"
|
6
6
|
|
7
7
|
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
8
|
-
|
8
|
+
InstrumentedClient::INDICES_METHODS.each do |method_name|
|
9
9
|
define_method("index_#{method_name}") do |event|
|
10
10
|
log_event(event)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
InstrumentedClient::INDEX_METHODS.each do |method_name|
|
15
15
|
define_method(method_name) do |event|
|
16
16
|
log_event(event)
|
17
17
|
end
|
data/lib/elasticity/search.rb
CHANGED
@@ -21,7 +21,10 @@ module Elasticity
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_count_args
|
24
|
-
{ index: @index_name, type: @document_type
|
24
|
+
{ index: @index_name, type: @document_type}.tap do |args|
|
25
|
+
body = @body.slice(:query)
|
26
|
+
args[:body] = body if body.present?
|
27
|
+
end
|
25
28
|
end
|
26
29
|
|
27
30
|
def to_search_args
|
data/lib/elasticity/version.rb
CHANGED
@@ -31,6 +31,11 @@ RSpec.describe "Persistence", elasticsearch: true do
|
|
31
31
|
subject.delete_index
|
32
32
|
end
|
33
33
|
|
34
|
+
it "counts empty search" do
|
35
|
+
count = subject.search({}).count
|
36
|
+
expect(count).to eq 0
|
37
|
+
end
|
38
|
+
|
34
39
|
it "successfully index, update, search, count and delete" do
|
35
40
|
john = subject.new(name: "John", birthdate: "1985-10-31")
|
36
41
|
mari = subject.new(name: "Mari", birthdate: "1986-09-24")
|
@@ -92,6 +97,11 @@ RSpec.describe "Persistence", elasticsearch: true do
|
|
92
97
|
subject.delete_index
|
93
98
|
end
|
94
99
|
|
100
|
+
it "counts empty search" do
|
101
|
+
count = subject.search({}).count
|
102
|
+
expect(count).to eq 0
|
103
|
+
end
|
104
|
+
|
95
105
|
it "remaps to a different index transparently" do
|
96
106
|
john = subject.new(name: "John", birthdate: "1985-10-31")
|
97
107
|
mari = subject.new(name: "Mari", birthdate: "1986-09-24")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: es-elasticity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Kochenburger
|
@@ -242,3 +242,4 @@ test_files:
|
|
242
242
|
- spec/units/multi_search_spec.rb
|
243
243
|
- spec/units/search_spec.rb
|
244
244
|
- spec/units/strategies/single_index_spec.rb
|
245
|
+
has_rdoc:
|