elastic-rails 0.6.1 → 0.6.2

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: c0f277dfbb48f36dd5d37aec9678897754b6b348
4
- data.tar.gz: 4f799186d83a23ab54aff5c11fcb482c461536e5
3
+ metadata.gz: 90b6db33bed1636b6da9df58b85bcc09af897e4c
4
+ data.tar.gz: 5d5b72ba7731c3e650aa5df56fb40014c9aee787
5
5
  SHA512:
6
- metadata.gz: 2a1ed07c2514ef377743f87b8761b1e4005529a56781e6441219e9010a98e9edb63b715d7dfdbeb641e0f058da8251d2a58a9b9bab0ef86f8ad96b40f82d7432
7
- data.tar.gz: 86955585a269003324f70a85fea21bcffcd4fb284a3c50655bc078958c0b845569f5ea2f7b4c6978b1dfd78925d4bf579cefa84ebf1a9cbd7634bc5b244a5d9e
6
+ metadata.gz: 58dfe90b0d76dd018762f1dd0d9016a2abfd758df48025289395f000e03819b0cc0983457a37d2600b10e8c7392e2989543d1e0eeba88c9c90593a35ca050b9b
7
+ data.tar.gz: cc29015434afc2a7e5408547d89d830ee17a9d57afff15e6644cee2231b2e801042f195ba0a2d6fd899bb3a60cff6c21a6c4f8eedc2bef1ff9a9ad7c594fbc65
@@ -3,12 +3,14 @@ module Elastic::Commands
3
3
  :index, collection: nil, batch_size: 10000, verbose: false
4
4
  )
5
5
  def perform
6
- if collection.present?
7
- import_collection
8
- else
9
- targets.each { |target| import_target(target) }
6
+ index.adaptor.with_settings(refresh_interval: -1) do
7
+ if collection.present?
8
+ import_collection
9
+ else
10
+ targets.each { |target| import_target(target) }
11
+ end
12
+ flush
10
13
  end
11
- flush
12
14
  end
13
15
 
14
16
  private
@@ -1,5 +1,10 @@
1
1
  module Elastic::Core
2
2
  class Adaptor
3
+ DEFAULT_SETTINGS = {
4
+ refresh_interval: '1s',
5
+ number_of_replicas: 1
6
+ }
7
+
3
8
  def initialize(_suffix)
4
9
  @suffix = _suffix
5
10
  end
@@ -63,17 +68,23 @@ module Elastic::Core
63
68
  end
64
69
 
65
70
  def bulk_index(_documents)
66
- body = _documents.map do |doc|
67
- { 'index' => doc.merge('_index' => index_name) }
68
- end
71
+ body = _documents.map { |doc| { 'index' => doc } }
69
72
 
70
73
  retry_on_temporary_error('bulk indexing') do
71
- api_client.bulk body: body
74
+ api_client.bulk build_options(body: body)
72
75
  end
73
76
 
74
77
  self
75
78
  end
76
79
 
80
+ def with_settings(_options)
81
+ _options = DEFAULT_SETTINGS.merge _options
82
+ api_client.indices.put_settings build_options(body: { index: _options })
83
+ yield
84
+ ensure
85
+ api_client.indices.put_settings build_options(body: { index: DEFAULT_SETTINGS })
86
+ end
87
+
77
88
  def refresh
78
89
  api_client.indices.refresh build_options
79
90
  self
@@ -1,3 +1,3 @@
1
1
  module Elastic
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignacio Baixas