elastic 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 300fcf49159b96f8bf8effa5064b4210cc25b956e37024a097b633295eb1b945
4
- data.tar.gz: 76f423a4a1cb831eaec79c4ca6c4f16fe1189c422308215d797678634e8afa48
3
+ metadata.gz: 40470008edcc06c100c7087ad96588d162d5a575df71520df10ab786f263aee1
4
+ data.tar.gz: 81b226cf69b05df6d921372c4fe00310c1ce6d7cd46c20ea09bc95e2eec0c648
5
5
  SHA512:
6
- metadata.gz: ab02d029f6d2ec592e400eee47dec95afde9b86ef98774a73ae5dbbba4cf5e3c3401502f562db521c9dd2acc18a96c123fea74ca72d3e0cc89b4b8600390e8a0
7
- data.tar.gz: d27dc6e7947500b7c9668992437c3bf1a2628200bbb6f53b8595ad08f1ba2f3e766704f3a2e55af2d7dd37ad1a52f31a23858aa32e085ad4be5cbf2a68e81755
6
+ metadata.gz: cb8f155022d47d59800282672aba44d7847b81e86e464c209cd48af8fe626a83c4dc4529e27a35fa49deaabf3cfaf3b2baf2592934290eb5cd43a0900174cf67
7
+ data.tar.gz: eb67faf1c159907f07409e7f7146258904231133008f5344631935b0c471bb0ddc959aba5183dd1a469fe8a6bf50836fb1c4fbf8c6a282e62fc9cbf803ad305d
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Elastic
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.0
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-09 00:00:00.000000000 Z
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.2.15
144
+ rubygems_version: 3.1.4
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Elasticsearch utilities