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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a99e45f5ef9e625931db6d140fa43abeebb0719e
4
- data.tar.gz: 9b8542e68c9c00ce4109c5a67c227dae68804a03
3
+ metadata.gz: e94caa98bd83150c6799ad689e65a7c8e66816e6
4
+ data.tar.gz: 1d3114e6576347abf45dac9c41dc449cd0b298e2
5
5
  SHA512:
6
- metadata.gz: ac65a4a90720bb4aa1887dd1f47d33e27ad623a9dfb1f0378d3578608ede383d58b85da0d1a7f5a0eaf36fa803ce52de16a98eca665efded0ab9d61bf69de289
7
- data.tar.gz: f75cc2f3ae6c90ed308f9ead04fe8eadde0c3ec052c65cce87a56708a483966285ac0fd0c993595c487ce170b7ddba51dbbe94d0102dd9fa96825466af44d062
6
+ metadata.gz: f4601bdaa5a6d904c6374ae2b733473258e2e5bf8dbc343114a7d8b9e0a230074e2206adb15123371ce7bd9bed3ac633454e6bd8809877fde26175d9adf603c1
7
+ data.tar.gz: 37019fb734b5694b722bc6175ab4ebe41835cedcf06eff307e1408c6db3ce74c1c6680d2ebe1be4c8624e6e4ef594c5383d2b642fc0a6bc5ec55afb588114eb2
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Elasticity
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
@@ -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.5
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-03-30 00:00:00.000000000 Z
11
+ date: 2015-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler