elastic_searchable 0.6.2 → 0.6.3

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.
@@ -60,6 +60,7 @@ module ElasticSearchable
60
60
  # :include - passed to find_in_batches to hydrate objects
61
61
  # see http://www.elasticsearch.org/guide/reference/api/bulk.html
62
62
  def reindex(options = {})
63
+ self.update_index_mapping
63
64
  batch = options.delete(:batch) || 1
64
65
  options[:batch_size] ||= 1000
65
66
  options[:start] ||= (batch - 1) * options[:batch_size]
@@ -78,7 +79,11 @@ module ElasticSearchable
78
79
  puts "Unable to bulk index record: #{record.inspect} [#{e.message}]"
79
80
  end
80
81
  end
81
- ElasticSearchable.request(:put, '/_bulk', :body => "\n#{actions.join("\n")}\n") if actions.any?
82
+ begin
83
+ ElasticSearchable.request(:put, '/_bulk', :body => "\n#{actions.join("\n")}\n") if actions.any?
84
+ rescue ElasticError => e
85
+ puts "Error indexing batch ##{batch}: #{e.message}"
86
+ end
82
87
  end
83
88
  end
84
89
 
@@ -1,4 +1,4 @@
1
1
  module ElasticSearchable
2
- VERSION = '0.6.2'
2
+ VERSION = '0.6.3'
3
3
  end
4
4
 
@@ -116,6 +116,10 @@ class TestElasticSearchable < Test::Unit::TestCase
116
116
  @second_post = Post.create :title => 'foo', :body => "second bar"
117
117
  Post.clean_index
118
118
  end
119
+ should 'not raise error if error occurs reindexing model' do
120
+ ElasticSearchable.expects(:request).raises(ElasticSearchable::ElasticError.new('faux error'))
121
+ Post.reindex
122
+ end
119
123
  context 'Post.reindex' do
120
124
  setup do
121
125
  Post.reindex
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_searchable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Sonnek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-25 00:00:00 -05:00
18
+ date: 2011-03-30 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  requirements: []
230
230
 
231
231
  rubyforge_project: elastic_searchable
232
- rubygems_version: 1.6.1
232
+ rubygems_version: 1.6.2
233
233
  signing_key:
234
234
  specification_version: 3
235
235
  summary: elastic search for activerecord