elastic-rails 0.8.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d00b5b5c6f5a1bc7701c5d635198e88094e65ea
4
- data.tar.gz: 09550318bf8064a884b097576ff2aa15d6702daa
3
+ metadata.gz: 4ccf947047bcebb5042dddebb851e017da2f9a5b
4
+ data.tar.gz: 459d2dd8391984dc5824cd1e7b5465c5d950b615
5
5
  SHA512:
6
- metadata.gz: 5be452213033d0d2fb6a868d65709ed68260cfffb847566dd3ac2094a571c69aba9b6b75a06455f85091d5a35a12269cab78b68435efd355af40199cb1e8f4c1
7
- data.tar.gz: 03b952d5219a6c47606db579f1b06c73c8a9c326949ce12da855f995c9053adfdd458b5e1570ae71296446a8412b4a4485c9615d3dc4d8800ca0aedc9a95ced8
6
+ metadata.gz: 9faed007e581dfb072a6f39c789e04911c026e2bcaa77bf3024e57407f6100eed2d9302bf46171cd5bb17d09b6a9d8ab87b224fec7ca77dab5bbc4d30b8d1ea5
7
+ data.tar.gz: 9bcd9d07542c303efa0df810924f5629a43ba217326a2fd4600d0a0eb88bf07f3328d3f9cd097093662f99dc54324e354c7c0aa4c828a0d2ec69b1a80e49990b
@@ -150,6 +150,15 @@ module Elastic::Core
150
150
  end
151
151
  end
152
152
 
153
+ def remove_orphaned_indices
154
+ _, rolling_index = resolve_write_indices
155
+
156
+ unless rolling_index.nil?
157
+ Elastic.logger.info "Removing orphan index #{rolling_index}"
158
+ api.indices.delete index: rolling_index
159
+ end
160
+ end
161
+
153
162
  private
154
163
 
155
164
  def wait_for_index_to_stabilize
@@ -17,6 +17,12 @@ namespace :es do
17
17
  Elastic.reindex args.index
18
18
  end
19
19
 
20
+ desc "Elastic: Cleanups orphan indices"
21
+ task cleanup: :environment do
22
+ Elastic.configure logger: Logger.new(STDOUT)
23
+ Elastic.cleanup
24
+ end
25
+
20
26
  desc "Elastic: Lists indices stats"
21
27
  task :stats, [:index] => :environment do |_, args|
22
28
  Elastic.configure logger: Logger.new(STDOUT)
@@ -28,6 +28,11 @@ module Elastic::Railties
28
28
  end
29
29
  end
30
30
 
31
+ def cleanup
32
+ logger.info "Searching for orphan indices"
33
+ indices.each { |index| index.connector.remove_orphaned_indices }
34
+ end
35
+
31
36
  def drop(_index = nil)
32
37
  logger.info "Dropping all indices" if _index.nil?
33
38
  indices(_index).each &:drop
@@ -1,3 +1,3 @@
1
1
  module Elastic
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignacio Baixas