elastic 0.3.0 → 0.3.1
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 +4 -4
- data/lib/elastic/client.rb +5 -2
- data/lib/elastic/index.rb +10 -8
- data/lib/elastic/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40470008edcc06c100c7087ad96588d162d5a575df71520df10ab786f263aee1
|
4
|
+
data.tar.gz: 81b226cf69b05df6d921372c4fe00310c1ce6d7cd46c20ea09bc95e2eec0c648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb8f155022d47d59800282672aba44d7847b81e86e464c209cd48af8fe626a83c4dc4529e27a35fa49deaabf3cfaf3b2baf2592934290eb5cd43a0900174cf67
|
7
|
+
data.tar.gz: eb67faf1c159907f07409e7f7146258904231133008f5344631935b0c471bb0ddc959aba5183dd1a469fe8a6bf50836fb1c4fbf8c6a282e62fc9cbf803ad305d
|
data/lib/elastic/client.rb
CHANGED
@@ -77,13 +77,14 @@ module Elastic
|
|
77
77
|
execute { bulk(options) }
|
78
78
|
end
|
79
79
|
|
80
|
-
def bulk_operation(action, index, id, data = {})
|
80
|
+
def bulk_operation(action, index, id, data = {}, query_params = {})
|
81
81
|
metadata = {
|
82
82
|
_index: index,
|
83
83
|
_id: id,
|
84
84
|
}
|
85
85
|
|
86
86
|
metadata[:data] = data if data && !data.empty?
|
87
|
+
metadata.merge!(query_params) unless query_params.empty?
|
87
88
|
|
88
89
|
{ action.to_sym => metadata }
|
89
90
|
end
|
@@ -92,7 +93,7 @@ module Elastic
|
|
92
93
|
execute { get(id: id, index: index) }
|
93
94
|
end
|
94
95
|
|
95
|
-
def mget(index, ids)
|
96
|
+
def mget(index, ids, query_params = {})
|
96
97
|
ids = Array(ids)
|
97
98
|
return [] if ids.empty?
|
98
99
|
|
@@ -105,6 +106,8 @@ module Elastic
|
|
105
106
|
}
|
106
107
|
}
|
107
108
|
|
109
|
+
options.merge!(query_params) unless query_params.empty?
|
110
|
+
|
108
111
|
results = execute { mget(options) }
|
109
112
|
results['docs'].select { |doc| doc['found'] }
|
110
113
|
end
|
data/lib/elastic/index.rb
CHANGED
@@ -65,12 +65,12 @@ module Elastic
|
|
65
65
|
response['count']
|
66
66
|
end
|
67
67
|
|
68
|
-
def get(id)
|
69
|
-
mget([id]).first
|
68
|
+
def get(id, query_params: {})
|
69
|
+
mget([id], query_params: query_params).first
|
70
70
|
end
|
71
71
|
|
72
|
-
def mget(ids)
|
73
|
-
docs = client.mget(index_name, ids)
|
72
|
+
def mget(ids, query_params: {})
|
73
|
+
docs = client.mget(index_name, ids, query_params)
|
74
74
|
docs.map { |doc| source_with_id(doc) }
|
75
75
|
end
|
76
76
|
|
@@ -91,17 +91,19 @@ module Elastic
|
|
91
91
|
docs.lazy.map { |doc| doc['_id'] }
|
92
92
|
end
|
93
93
|
|
94
|
-
def bulk(action, id, data
|
95
|
-
buffer << bulk_operation(action, id, data)
|
94
|
+
def bulk(action, id, data: {}, query_params: {})
|
95
|
+
buffer << bulk_operation(action, id, data, query_params)
|
96
96
|
end
|
97
97
|
|
98
|
-
def bulk_operation(action, id, data = {})
|
98
|
+
def bulk_operation(action, id, data = {}, query_params = {})
|
99
99
|
metadata = {
|
100
100
|
_index: index_name,
|
101
101
|
_id: id,
|
102
|
-
retry_on_conflict: 3
|
102
|
+
retry_on_conflict: 3,
|
103
103
|
}
|
104
104
|
|
105
|
+
metadata.merge!(query_params) unless query_params.empty?
|
106
|
+
|
105
107
|
if action.to_sym == :upsert
|
106
108
|
data ||= {}
|
107
109
|
data[:doc_as_upsert] = true
|
data/lib/elastic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Szajbe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.1.4
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Elasticsearch utilities
|