elastictastic 0.10.4 → 0.10.5
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.
- data/README.md +13 -1
- data/lib/elastictastic/basic_document.rb +8 -2
- data/lib/elastictastic/index.rb +4 -0
- data/lib/elastictastic/properties.rb +2 -1
- data/lib/elastictastic/version.rb +1 -1
- data/spec/examples/document_spec.rb +20 -0
- data/spec/examples/optimistic_locking_spec.rb +0 -1
- metadata +84 -140
data/README.md
CHANGED
@@ -6,6 +6,8 @@ is to define model classes which use ElasticSearch as a primary
|
|
6
6
|
document-oriented data store, and to expose ElasticSearch's search functionality
|
7
7
|
to query for those models.
|
8
8
|
|
9
|
+
[](http://travis-ci.org/brewster/elastictastic)
|
10
|
+
|
9
11
|
## Dependencies ##
|
10
12
|
|
11
13
|
Elastictastic requires Ruby 1.9 and ActiveSupport 3. Elastictastic does not
|
@@ -469,7 +471,17 @@ Post.highlight { fields(:title => {}) }.find_in_batches do |batch|
|
|
469
471
|
end
|
470
472
|
```
|
471
473
|
|
472
|
-
Both `find_each` and `find_in_batches` accept a
|
474
|
+
Both `find_each` and `find_in_batches` accept a `:batch_size` option.
|
475
|
+
|
476
|
+
## Support & Bugs ##
|
477
|
+
|
478
|
+
If you find a bug, feel free to
|
479
|
+
[open an issue](https://github.com/brewster/elastictastic/issues/new) on GitHub.
|
480
|
+
Pull requests are most welcome.
|
481
|
+
|
482
|
+
For questions or feedback, hit up our mailing list at
|
483
|
+
[elastictastic@groups.google.com](http://groups.google.com/group/elastictastic)
|
484
|
+
or find outoftime on the #elasticsearch IRC channel on Freenode.
|
473
485
|
|
474
486
|
## License ##
|
475
487
|
|
@@ -116,6 +116,8 @@ module Elastictastic
|
|
116
116
|
:script_fields, :preference, :facets, :routing,
|
117
117
|
:to => :current_scope
|
118
118
|
|
119
|
+
attr_writer :default_index
|
120
|
+
|
119
121
|
def mapping
|
120
122
|
mapping_for_type = { 'properties' => properties }
|
121
123
|
mapping_for_type['_boost'] = @_boost if @_boost
|
@@ -143,7 +145,11 @@ module Elastictastic
|
|
143
145
|
private
|
144
146
|
|
145
147
|
def default_scope
|
146
|
-
in_index(
|
148
|
+
in_index(default_index)
|
149
|
+
end
|
150
|
+
|
151
|
+
def default_index
|
152
|
+
@default_index || Index.default
|
147
153
|
end
|
148
154
|
end
|
149
155
|
|
@@ -192,7 +198,7 @@ module Elastictastic
|
|
192
198
|
end
|
193
199
|
|
194
200
|
def ==(other)
|
195
|
-
index == other.index && id == other.id
|
201
|
+
index == other.index && self.class == other.class && id == other.id
|
196
202
|
end
|
197
203
|
|
198
204
|
def attributes
|
data/lib/elastictastic/index.rb
CHANGED
@@ -262,7 +262,8 @@ module Elastictastic
|
|
262
262
|
def deserialize_value(field_name, value)
|
263
263
|
return nil if value.nil?
|
264
264
|
if self.class.properties_for_field(field_name)['type'].to_s == 'date'
|
265
|
-
|
265
|
+
case value
|
266
|
+
when Fixnum, Bignum
|
266
267
|
sec, usec = value / 1000, (value % 1000) * 1000
|
267
268
|
Time.at(sec, usec).utc
|
268
269
|
else
|
@@ -659,4 +659,24 @@ describe Elastictastic::Document do
|
|
659
659
|
end
|
660
660
|
end
|
661
661
|
end
|
662
|
+
|
663
|
+
describe '#==' do
|
664
|
+
it 'should return true if index, id and class of both objects are equal' do
|
665
|
+
first_post = Post.new(index: "post", title: "Hello, world!")
|
666
|
+
first_post.id = 1
|
667
|
+
other_post = Post.new(index: "post", title: "Hello, world!")
|
668
|
+
other_post.id = 1
|
669
|
+
|
670
|
+
other_post.should eq first_post
|
671
|
+
end
|
672
|
+
|
673
|
+
it 'should fail when classes are not equal' do
|
674
|
+
post = Post.new
|
675
|
+
post.id = 1
|
676
|
+
photo = Photo.new
|
677
|
+
photo.id = 1
|
678
|
+
|
679
|
+
photo.should_not eq post
|
680
|
+
end
|
681
|
+
end
|
662
682
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastictastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-12-08 00:00:00.000000000Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirement: &24452880 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -23,15 +23,10 @@ dependencies:
|
|
23
23
|
version: '3.0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
27
|
-
none: false
|
28
|
-
requirements:
|
29
|
-
- - ~>
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: '3.0'
|
26
|
+
version_requirements: *24452880
|
32
27
|
- !ruby/object:Gem::Dependency
|
33
28
|
name: activemodel
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirement: &24452420 !ruby/object:Gem::Requirement
|
35
30
|
none: false
|
36
31
|
requirements:
|
37
32
|
- - ~>
|
@@ -39,15 +34,10 @@ dependencies:
|
|
39
34
|
version: '3.0'
|
40
35
|
type: :runtime
|
41
36
|
prerelease: false
|
42
|
-
version_requirements:
|
43
|
-
none: false
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
37
|
+
version_requirements: *24452420
|
48
38
|
- !ruby/object:Gem::Dependency
|
49
39
|
name: hashie
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirement: &24452040 !ruby/object:Gem::Requirement
|
51
41
|
none: false
|
52
42
|
requirements:
|
53
43
|
- - ! '>='
|
@@ -55,15 +45,10 @@ dependencies:
|
|
55
45
|
version: '0'
|
56
46
|
type: :runtime
|
57
47
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
none: false
|
60
|
-
requirements:
|
61
|
-
- - ! '>='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0'
|
48
|
+
version_requirements: *24452040
|
64
49
|
- !ruby/object:Gem::Dependency
|
65
50
|
name: i18n
|
66
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirement: &24451580 !ruby/object:Gem::Requirement
|
67
52
|
none: false
|
68
53
|
requirements:
|
69
54
|
- - ! '>='
|
@@ -71,15 +56,10 @@ dependencies:
|
|
71
56
|
version: '0'
|
72
57
|
type: :runtime
|
73
58
|
prerelease: false
|
74
|
-
version_requirements:
|
75
|
-
none: false
|
76
|
-
requirements:
|
77
|
-
- - ! '>='
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: '0'
|
59
|
+
version_requirements: *24451580
|
80
60
|
- !ruby/object:Gem::Dependency
|
81
61
|
name: multi_json
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
62
|
+
requirement: &24451160 !ruby/object:Gem::Requirement
|
83
63
|
none: false
|
84
64
|
requirements:
|
85
65
|
- - ! '>='
|
@@ -87,15 +67,10 @@ dependencies:
|
|
87
67
|
version: '0'
|
88
68
|
type: :runtime
|
89
69
|
prerelease: false
|
90
|
-
version_requirements:
|
91
|
-
none: false
|
92
|
-
requirements:
|
93
|
-
- - ! '>='
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
70
|
+
version_requirements: *24451160
|
96
71
|
- !ruby/object:Gem::Dependency
|
97
72
|
name: rspec
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirement: &24450660 !ruby/object:Gem::Requirement
|
99
74
|
none: false
|
100
75
|
requirements:
|
101
76
|
- - ~>
|
@@ -103,15 +78,10 @@ dependencies:
|
|
103
78
|
version: '2.0'
|
104
79
|
type: :development
|
105
80
|
prerelease: false
|
106
|
-
version_requirements:
|
107
|
-
none: false
|
108
|
-
requirements:
|
109
|
-
- - ~>
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '2.0'
|
81
|
+
version_requirements: *24450660
|
112
82
|
- !ruby/object:Gem::Dependency
|
113
83
|
name: fakeweb
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirement: &24450160 !ruby/object:Gem::Requirement
|
115
85
|
none: false
|
116
86
|
requirements:
|
117
87
|
- - ~>
|
@@ -119,31 +89,10 @@ dependencies:
|
|
119
89
|
version: '1.3'
|
120
90
|
type: :development
|
121
91
|
prerelease: false
|
122
|
-
version_requirements:
|
123
|
-
none: false
|
124
|
-
requirements:
|
125
|
-
- - ~>
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '1.3'
|
128
|
-
- !ruby/object:Gem::Dependency
|
129
|
-
name: debugger
|
130
|
-
requirement: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
|
-
requirements:
|
133
|
-
- - ! '>='
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
version: '0'
|
136
|
-
type: :development
|
137
|
-
prerelease: false
|
138
|
-
version_requirements: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
|
-
requirements:
|
141
|
-
- - ! '>='
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '0'
|
92
|
+
version_requirements: *24450160
|
144
93
|
- !ruby/object:Gem::Dependency
|
145
94
|
name: yard
|
146
|
-
requirement: !ruby/object:Gem::Requirement
|
95
|
+
requirement: &24449700 !ruby/object:Gem::Requirement
|
147
96
|
none: false
|
148
97
|
requirements:
|
149
98
|
- - ~>
|
@@ -151,12 +100,7 @@ dependencies:
|
|
151
100
|
version: '0.6'
|
152
101
|
type: :development
|
153
102
|
prerelease: false
|
154
|
-
version_requirements:
|
155
|
-
none: false
|
156
|
-
requirements:
|
157
|
-
- - ~>
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0.6'
|
103
|
+
version_requirements: *24449700
|
160
104
|
description: ! 'Elastictastic is an object-document mapper and lightweight API adapter
|
161
105
|
for
|
162
106
|
|
@@ -173,74 +117,74 @@ extensions: []
|
|
173
117
|
extra_rdoc_files:
|
174
118
|
- README.md
|
175
119
|
files:
|
176
|
-
- lib/elastictastic.rb
|
177
|
-
- lib/elastictastic/optimistic_locking.rb
|
178
|
-
- lib/elastictastic/server_error.rb
|
179
|
-
- lib/elastictastic/document.rb
|
180
|
-
- lib/elastictastic/nested_document.rb
|
181
|
-
- lib/elastictastic/child_collection_proxy.rb
|
182
|
-
- lib/elastictastic/mass_assignment_security.rb
|
183
|
-
- lib/elastictastic/scope_builder.rb
|
184
|
-
- lib/elastictastic/util.rb
|
185
|
-
- lib/elastictastic/index.rb
|
186
|
-
- lib/elastictastic/bulk_persistence_strategy.rb
|
187
|
-
- lib/elastictastic/basic_document.rb
|
188
|
-
- lib/elastictastic/thrift/rest.rb
|
189
|
-
- lib/elastictastic/thrift/constants.rb
|
190
|
-
- lib/elastictastic/thrift/types.rb
|
191
120
|
- lib/elastictastic/multi_search.rb
|
192
|
-
- lib/elastictastic/
|
193
|
-
- lib/elastictastic/
|
194
|
-
- lib/elastictastic/discrete_persistence_strategy.rb
|
195
|
-
- lib/elastictastic/callbacks.rb
|
121
|
+
- lib/elastictastic/transport_methods.rb
|
122
|
+
- lib/elastictastic/basic_document.rb
|
196
123
|
- lib/elastictastic/observer.rb
|
124
|
+
- lib/elastictastic/middleware.rb
|
125
|
+
- lib/elastictastic/child_collection_proxy.rb
|
126
|
+
- lib/elastictastic/dirty.rb
|
127
|
+
- lib/elastictastic/rotor.rb
|
128
|
+
- lib/elastictastic/errors.rb
|
129
|
+
- lib/elastictastic/scope.rb
|
130
|
+
- lib/elastictastic/discrete_persistence_strategy.rb
|
131
|
+
- lib/elastictastic/parent_child.rb
|
132
|
+
- lib/elastictastic/adapter.rb
|
197
133
|
- lib/elastictastic/embedded_document.rb
|
198
|
-
- lib/elastictastic/
|
199
|
-
- lib/elastictastic/
|
200
|
-
- lib/elastictastic/
|
201
|
-
- lib/elastictastic/
|
202
|
-
- lib/elastictastic/
|
203
|
-
- lib/elastictastic/
|
134
|
+
- lib/elastictastic/new_relic_instrumentation.rb
|
135
|
+
- lib/elastictastic/optimistic_locking.rb
|
136
|
+
- lib/elastictastic/callbacks.rb
|
137
|
+
- lib/elastictastic/util.rb
|
138
|
+
- lib/elastictastic/nested_document.rb
|
139
|
+
- lib/elastictastic/association.rb
|
204
140
|
- lib/elastictastic/client.rb
|
141
|
+
- lib/elastictastic/document.rb
|
205
142
|
- lib/elastictastic/properties.rb
|
206
|
-
- lib/elastictastic/
|
143
|
+
- lib/elastictastic/test_helpers.rb
|
144
|
+
- lib/elastictastic/search.rb
|
145
|
+
- lib/elastictastic/thrift/types.rb
|
146
|
+
- lib/elastictastic/thrift/rest.rb
|
147
|
+
- lib/elastictastic/thrift/constants.rb
|
207
148
|
- lib/elastictastic/multi_get.rb
|
208
|
-
- lib/elastictastic/
|
149
|
+
- lib/elastictastic/mass_assignment_security.rb
|
150
|
+
- lib/elastictastic/server_error.rb
|
151
|
+
- lib/elastictastic/version.rb
|
152
|
+
- lib/elastictastic/scope_builder.rb
|
153
|
+
- lib/elastictastic/persistence.rb
|
154
|
+
- lib/elastictastic/observing.rb
|
155
|
+
- lib/elastictastic/index.rb
|
156
|
+
- lib/elastictastic/validations.rb
|
157
|
+
- lib/elastictastic/bulk_persistence_strategy.rb
|
209
158
|
- lib/elastictastic/field.rb
|
210
|
-
- lib/elastictastic/scope.rb
|
211
159
|
- lib/elastictastic/scoped.rb
|
212
|
-
- lib/elastictastic/
|
213
|
-
- lib/elastictastic/
|
214
|
-
- lib/elastictastic/transport_methods.rb
|
215
|
-
- lib/elastictastic/middleware.rb
|
160
|
+
- lib/elastictastic/thrift_adapter.rb
|
161
|
+
- lib/elastictastic/railtie.rb
|
216
162
|
- lib/elastictastic/configuration.rb
|
217
|
-
- lib/elastictastic
|
218
|
-
-
|
219
|
-
-
|
163
|
+
- lib/elastictastic.rb
|
164
|
+
- spec/models/photo.rb
|
165
|
+
- spec/models/post.rb
|
166
|
+
- spec/models/blog.rb
|
167
|
+
- spec/models/author.rb
|
168
|
+
- spec/models/post_observer.rb
|
169
|
+
- spec/models/comment.rb
|
220
170
|
- spec/environment.rb
|
171
|
+
- spec/examples/callbacks_spec.rb
|
172
|
+
- spec/examples/mass_assignment_security_spec.rb
|
173
|
+
- spec/examples/rotor_spec.rb
|
174
|
+
- spec/examples/middleware_spec.rb
|
175
|
+
- spec/examples/optimistic_locking_spec.rb
|
176
|
+
- spec/examples/parent_child_spec.rb
|
177
|
+
- spec/examples/scope_spec.rb
|
221
178
|
- spec/examples/bulk_persistence_strategy_spec.rb
|
222
|
-
- spec/examples/document_spec.rb
|
223
179
|
- spec/examples/properties_spec.rb
|
224
|
-
- spec/examples/validation_spec.rb
|
225
|
-
- spec/examples/optimistic_locking_spec.rb
|
226
|
-
- spec/examples/middleware_spec.rb
|
227
|
-
- spec/examples/mass_assignment_security_spec.rb
|
228
|
-
- spec/examples/dirty_spec.rb
|
229
|
-
- spec/examples/spec_helper.rb
|
230
180
|
- spec/examples/multi_search_spec.rb
|
231
|
-
- spec/examples/rotor_spec.rb
|
232
|
-
- spec/examples/callbacks_spec.rb
|
233
181
|
- spec/examples/multi_get_spec.rb
|
234
|
-
- spec/examples/scope_spec.rb
|
235
|
-
- spec/examples/parent_child_spec.rb
|
236
|
-
- spec/examples/observing_spec.rb
|
237
182
|
- spec/examples/search_spec.rb
|
238
|
-
- spec/
|
239
|
-
- spec/
|
240
|
-
- spec/
|
241
|
-
- spec/
|
242
|
-
- spec/
|
243
|
-
- spec/models/comment.rb
|
183
|
+
- spec/examples/document_spec.rb
|
184
|
+
- spec/examples/dirty_spec.rb
|
185
|
+
- spec/examples/validation_spec.rb
|
186
|
+
- spec/examples/observing_spec.rb
|
187
|
+
- spec/examples/spec_helper.rb
|
244
188
|
- spec/support/fakeweb_request_history.rb
|
245
189
|
- README.md
|
246
190
|
- LICENSE
|
@@ -266,26 +210,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
210
|
requirements:
|
267
211
|
- ElasticSearch
|
268
212
|
rubyforge_project:
|
269
|
-
rubygems_version: 1.8.
|
213
|
+
rubygems_version: 1.8.15
|
270
214
|
signing_key:
|
271
215
|
specification_version: 3
|
272
216
|
summary: Object-document mapper for ElasticSearch
|
273
217
|
test_files:
|
218
|
+
- spec/examples/callbacks_spec.rb
|
219
|
+
- spec/examples/mass_assignment_security_spec.rb
|
220
|
+
- spec/examples/rotor_spec.rb
|
221
|
+
- spec/examples/middleware_spec.rb
|
222
|
+
- spec/examples/optimistic_locking_spec.rb
|
223
|
+
- spec/examples/parent_child_spec.rb
|
224
|
+
- spec/examples/scope_spec.rb
|
274
225
|
- spec/examples/bulk_persistence_strategy_spec.rb
|
275
|
-
- spec/examples/document_spec.rb
|
276
226
|
- spec/examples/properties_spec.rb
|
277
|
-
- spec/examples/validation_spec.rb
|
278
|
-
- spec/examples/optimistic_locking_spec.rb
|
279
|
-
- spec/examples/middleware_spec.rb
|
280
|
-
- spec/examples/mass_assignment_security_spec.rb
|
281
|
-
- spec/examples/dirty_spec.rb
|
282
|
-
- spec/examples/spec_helper.rb
|
283
227
|
- spec/examples/multi_search_spec.rb
|
284
|
-
- spec/examples/rotor_spec.rb
|
285
|
-
- spec/examples/callbacks_spec.rb
|
286
228
|
- spec/examples/multi_get_spec.rb
|
287
|
-
- spec/examples/scope_spec.rb
|
288
|
-
- spec/examples/parent_child_spec.rb
|
289
|
-
- spec/examples/observing_spec.rb
|
290
229
|
- spec/examples/search_spec.rb
|
230
|
+
- spec/examples/document_spec.rb
|
231
|
+
- spec/examples/dirty_spec.rb
|
232
|
+
- spec/examples/validation_spec.rb
|
233
|
+
- spec/examples/observing_spec.rb
|
234
|
+
- spec/examples/spec_helper.rb
|
291
235
|
has_rdoc: true
|