mongoid-elasticsearch 0.4.0 → 0.4.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: 58ac499ba39b4b840bbf99df12f67d7e87008acb
4
- data.tar.gz: 9ae20ac236948c7b2124239fb159e5b860d8e2a8
3
+ metadata.gz: e4f292ee8adb28db5b0013bf8357627c9df82865
4
+ data.tar.gz: 6cad535741df733ba787d29f1f4c0f2233dce2ee
5
5
  SHA512:
6
- metadata.gz: 424670a23b52bc88031c52743c55a117d812913ac830bc7f5f1ac79709df33d329495f7abec3955849c50a728ae0dcac2feb5f7a09ea5983748c98e3aa4b38be
7
- data.tar.gz: a11695126ec22930873d678a1fac9053a18e06d30ce5713ab20d4557eb0e2d02bcc5fa9c4cb9f5fdf90ca69a09ac8a72cb8ee8e9a08c146ace2d9faa61233137
6
+ metadata.gz: 4e410de984a20d827035416a6a6e44ea628f9b63c6710d2ff5447059dea1230505edbd58b1029a399699fc93fc490c1c54b164f0b441a8c4783de8b10ee469f3
7
+ data.tar.gz: 4a9509adc2252f866d0069ca080d462dea4bd81fd9628d50e4bf5affb7f5b22273a04029e1d50c8c9f328078547255a12bf1e144653a2438dcf7af40ad497050
data/README.md CHANGED
@@ -96,7 +96,9 @@ Or install it yourself as:
96
96
 
97
97
  search syntax docs: http://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Actions#search-instance_method
98
98
 
99
- more docs: http://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Actions
99
+ ES Actions docs: http://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Actions
100
+
101
+ ES Indices docs: http://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Indices/Actions
100
102
 
101
103
  ES docs: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index.html
102
104
 
@@ -172,6 +174,12 @@ index definition options and custom model serialization:
172
174
 
173
175
  ### Reindexing
174
176
 
177
+ #### Simple bulk
178
+
179
+ This is the preferred (fastest) method to reindex everything
180
+
181
+ Music::Video.es.index_all
182
+
175
183
  #### Simple
176
184
 
177
185
  Communities::Thread.es.index.reset
@@ -179,7 +187,7 @@ index definition options and custom model serialization:
179
187
  ingr.es_update
180
188
  end
181
189
 
182
- #### Bulk with progress bar
190
+ #### Bulk with [progress bar](http://rubygems.org/gems/ruby-progressbar)
183
191
 
184
192
  pb = nil
185
193
  Music::Video.es.index_all do |steps, step|
@@ -195,7 +203,12 @@ index definition options and custom model serialization:
195
203
  - :model - create a model instance from data stored in elasticsearch
196
204
 
197
205
  See more examples in specs.
198
-
206
+
207
+ #### Util
208
+
209
+ # Escape string so it can be safely passed to ES (removes all special characters)
210
+ Mongoid::Elasticsearch::Utils.clean(s)
211
+
199
212
  ## Contributing
200
213
 
201
214
  1. Fork it
@@ -1,4 +1,4 @@
1
- require "mongoid/elasticsearch/version"
1
+ require 'mongoid/elasticsearch/version'
2
2
 
3
3
  require 'elasticsearch'
4
4
  require 'active_support/concern'
@@ -16,8 +16,6 @@ end
16
16
 
17
17
  module Mongoid
18
18
  module Elasticsearch
19
- INDEX_STEP = 300
20
-
21
19
  mattr_accessor :prefix
22
20
  self.prefix = ''
23
21
 
@@ -1,6 +1,7 @@
1
1
  module Mongoid
2
2
  module Elasticsearch
3
3
  class Es
4
+ INDEX_STEP = 100
4
5
  attr_reader :klass, :version
5
6
 
6
7
  def initialize(klass)
@@ -17,12 +18,12 @@ module Mongoid
17
18
  @index ||= Index.new(self)
18
19
  end
19
20
 
20
- def index_all
21
+ def index_all(step_size = INDEX_STEP)
21
22
  index.reset
22
23
  q = klass.order_by(_id: 1)
23
- steps = (q.count / INDEX_STEP) + 1
24
+ steps = (q.count / step_size) + 1
24
25
  steps.times do |step|
25
- docs = q.skip(step * INDEX_STEP).limit(INDEX_STEP)
26
+ docs = q.skip(step * step_size).limit(step_size)
26
27
  docs = docs.map do |obj|
27
28
  { index: {data: obj.as_indexed_json}.merge(_id: obj.id.to_s) }
28
29
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Elasticsearch
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-15 00:00:00.000000000 Z
11
+ date: 2013-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid