es-elasticity 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/elasticity/document.rb +9 -0
- data/lib/elasticity/version.rb +1 -1
- data/spec/functional/persistence_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e94caa98bd83150c6799ad689e65a7c8e66816e6
|
4
|
+
data.tar.gz: 1d3114e6576347abf45dac9c41dc449cd0b298e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4601bdaa5a6d904c6374ae2b733473258e2e5bf8dbc343114a7d8b9e0a230074e2206adb15123371ce7bd9bed3ac633454e6bd8809877fde26175d9adf603c1
|
7
|
+
data.tar.gz: 37019fb734b5694b722bc6175ab4ebe41835cedcf06eff307e1408c6db3ce74c1c6680d2ebe1be4c8624e6e4ef594c5383d2b642fc0a6bc5ec55afb588114eb2
|
data/lib/elasticity/document.rb
CHANGED
@@ -140,6 +140,15 @@ module Elasticity
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
+
# Bulk delete documents matching provided ids
|
144
|
+
def self.bulk_delete(ids)
|
145
|
+
self.strategy.bulk do |b|
|
146
|
+
ids.each do |id|
|
147
|
+
b.delete(self.document_type, id)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
143
152
|
# Define common attributes for all documents
|
144
153
|
attr_accessor :_id, :highlighted
|
145
154
|
|
data/lib/elasticity/version.rb
CHANGED
@@ -163,5 +163,23 @@ RSpec.describe "Persistence", elasticsearch: true do
|
|
163
163
|
results = subject.search(sort: :name)
|
164
164
|
expect(results.total).to eq(2010)
|
165
165
|
end
|
166
|
+
|
167
|
+
it "bulk indexes and delete" do
|
168
|
+
docs = 2000.times.map do |i|
|
169
|
+
subject.new(name: "User #{i}", birthdate: "#{rand(20)+1980}-#{rand(11)+1}-#{rand(28)+1}").tap(&:update)
|
170
|
+
end
|
171
|
+
|
172
|
+
subject.bulk_index(docs)
|
173
|
+
subject.flush_index
|
174
|
+
|
175
|
+
results = subject.search(from: 0, size: 3000)
|
176
|
+
expect(results.total).to eq 2000
|
177
|
+
|
178
|
+
subject.bulk_delete(results.documents.map(&:_id))
|
179
|
+
subject.flush_index
|
180
|
+
|
181
|
+
results = subject.search(from: 0, size: 3000)
|
182
|
+
expect(results.total).to eq 0
|
183
|
+
end
|
166
184
|
end
|
167
185
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: es-elasticity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Kochenburger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|