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 +4 -4
- data/README.md +16 -3
- data/lib/mongoid/elasticsearch.rb +1 -3
- data/lib/mongoid/elasticsearch/es.rb +4 -3
- data/lib/mongoid/elasticsearch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4f292ee8adb28db5b0013bf8357627c9df82865
|
4
|
+
data.tar.gz: 6cad535741df733ba787d29f1f4c0f2233dce2ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
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 /
|
24
|
+
steps = (q.count / step_size) + 1
|
24
25
|
steps.times do |step|
|
25
|
-
docs = q.skip(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
|
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.
|
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-
|
11
|
+
date: 2013-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|