elastic_searchable 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/README.md +1 -1
- data/lib/elastic_searchable/active_record_extensions.rb +1 -0
- data/lib/elastic_searchable/queries.rb +4 -0
- data/lib/elastic_searchable/version.rb +1 -1
- data/test/test_elastic_searchable.rb +13 -1
- metadata +88 -147
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use
|
1
|
+
rvm use ruby-1.9.2@elastic_searchable --create
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ gem 'elastic_searchable'
|
|
32
32
|
# config/initializers/elastic_searchable.rb
|
33
33
|
# (optional) customize elasticsearch host
|
34
34
|
# default is localhost:9200
|
35
|
-
ElasticSearchable.base_uri
|
35
|
+
ElasticSearchable.base_uri 'server:9200'
|
36
36
|
|
37
37
|
# (optional) customize elasticsearch paginator
|
38
38
|
# default is ElasticSearchable::Pagination::WillPaginate
|
@@ -40,6 +40,7 @@ module ElasticSearchable
|
|
40
40
|
backgrounded :delete_id_from_index => ElasticSearchable::Callbacks.backgrounded_options
|
41
41
|
end
|
42
42
|
|
43
|
+
attr_reader :hit # the hit json for this result
|
43
44
|
attr_accessor :index_lifecycle, :percolations
|
44
45
|
define_model_callbacks :index, :percolate, :only => :after
|
45
46
|
after_commit :update_index_on_create_backgrounded, :if => :should_index?, :on => :create
|
@@ -40,6 +40,10 @@ module ElasticSearchable
|
|
40
40
|
ids = hits['hits'].collect {|h| h['_id'].to_i }
|
41
41
|
results = self.find(ids).sort_by {|result| ids.index(result.id) }
|
42
42
|
|
43
|
+
results.each do |result|
|
44
|
+
result.instance_variable_set '@hit', hits['hits'][ids.index(result.id)]
|
45
|
+
end
|
46
|
+
|
43
47
|
ElasticSearchable::Paginator.handler.new(results, page, options[:size], hits['total'])
|
44
48
|
end
|
45
49
|
|
@@ -180,7 +180,7 @@ class TestElasticSearchable < Test::Unit::TestCase
|
|
180
180
|
Post.refresh_index
|
181
181
|
end
|
182
182
|
|
183
|
-
context 'searching
|
183
|
+
context 'searching on a term that returns one result' do
|
184
184
|
setup do
|
185
185
|
@results = Post.search 'first'
|
186
186
|
end
|
@@ -193,6 +193,18 @@ class TestElasticSearchable < Test::Unit::TestCase
|
|
193
193
|
assert_nil @results.previous_page
|
194
194
|
assert_nil @results.next_page
|
195
195
|
end
|
196
|
+
should 'have populated hit' do
|
197
|
+
assert_equal @results.first.hit['_id'], @first_post.id.to_s
|
198
|
+
end
|
199
|
+
end
|
200
|
+
context 'searching on a term that returns multiple results' do
|
201
|
+
setup do
|
202
|
+
@results = Post.search 'foo'
|
203
|
+
end
|
204
|
+
should 'have populated hit on each record with the correct hit json' do
|
205
|
+
assert_equal @results.first.hit['_id'], @first_post.id.to_s
|
206
|
+
assert_equal @results.last.hit['_id'], @second_post.id.to_s
|
207
|
+
end
|
196
208
|
end
|
197
209
|
|
198
210
|
context 'searching for results using a query Hash' do
|
metadata
CHANGED
@@ -1,178 +1,122 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_searchable
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
- 1
|
10
|
-
version: 1.3.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ryan Sonnek
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: activerecord
|
22
|
-
|
23
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2151908980 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 13
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 0
|
32
|
-
- 5
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 3.0.5
|
34
|
-
requirement: *id001
|
35
22
|
type: :runtime
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: httparty
|
38
23
|
prerelease: false
|
39
|
-
version_requirements:
|
24
|
+
version_requirements: *2151908980
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: httparty
|
27
|
+
requirement: &2151907880 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 7
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
- 6
|
48
|
-
- 0
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
49
32
|
version: 0.6.0
|
50
|
-
requirement: *id002
|
51
33
|
type: :runtime
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: backgrounded
|
54
34
|
prerelease: false
|
55
|
-
version_requirements:
|
35
|
+
version_requirements: *2151907880
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: backgrounded
|
38
|
+
requirement: &2151907180 !ruby/object:Gem::Requirement
|
56
39
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
hash: 3
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
- 7
|
64
|
-
- 0
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
65
43
|
version: 0.7.0
|
66
|
-
requirement: *id003
|
67
44
|
type: :runtime
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: multi_json
|
70
45
|
prerelease: false
|
71
|
-
version_requirements:
|
46
|
+
version_requirements: *2151907180
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: multi_json
|
49
|
+
requirement: &2151906480 !ruby/object:Gem::Requirement
|
72
50
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
hash: 23
|
77
|
-
segments:
|
78
|
-
- 1
|
79
|
-
- 0
|
80
|
-
- 0
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
81
54
|
version: 1.0.0
|
82
|
-
requirement: *id004
|
83
55
|
type: :runtime
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: rake
|
86
56
|
prerelease: false
|
87
|
-
version_requirements:
|
57
|
+
version_requirements: *2151906480
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: &2151905740 !ruby/object:Gem::Requirement
|
88
61
|
none: false
|
89
|
-
requirements:
|
90
|
-
- -
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
hash: 11
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
- 9
|
96
|
-
- 2
|
97
|
-
- 2
|
62
|
+
requirements:
|
63
|
+
- - =
|
64
|
+
- !ruby/object:Gem::Version
|
98
65
|
version: 0.9.2.2
|
99
|
-
requirement: *id005
|
100
66
|
type: :development
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
|
-
name: sqlite3
|
103
67
|
prerelease: false
|
104
|
-
version_requirements:
|
68
|
+
version_requirements: *2151905740
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: &2151905120 !ruby/object:Gem::Requirement
|
105
72
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
hash: 19
|
110
|
-
segments:
|
111
|
-
- 1
|
112
|
-
- 3
|
113
|
-
- 4
|
73
|
+
requirements:
|
74
|
+
- - =
|
75
|
+
- !ruby/object:Gem::Version
|
114
76
|
version: 1.3.4
|
115
|
-
requirement: *id006
|
116
77
|
type: :development
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: pry
|
119
78
|
prerelease: false
|
120
|
-
version_requirements:
|
79
|
+
version_requirements: *2151905120
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: pry
|
82
|
+
requirement: &2151904400 !ruby/object:Gem::Requirement
|
121
83
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
hash: 27
|
126
|
-
segments:
|
127
|
-
- 0
|
128
|
-
- 9
|
129
|
-
- 6
|
130
|
-
- 2
|
84
|
+
requirements:
|
85
|
+
- - =
|
86
|
+
- !ruby/object:Gem::Version
|
131
87
|
version: 0.9.6.2
|
132
|
-
requirement: *id007
|
133
88
|
type: :development
|
134
|
-
- !ruby/object:Gem::Dependency
|
135
|
-
name: shoulda
|
136
89
|
prerelease: false
|
137
|
-
version_requirements:
|
90
|
+
version_requirements: *2151904400
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: shoulda
|
93
|
+
requirement: &2151903660 !ruby/object:Gem::Requirement
|
138
94
|
none: false
|
139
|
-
requirements:
|
140
|
-
- -
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
hash: 37
|
143
|
-
segments:
|
144
|
-
- 2
|
145
|
-
- 11
|
146
|
-
- 3
|
95
|
+
requirements:
|
96
|
+
- - =
|
97
|
+
- !ruby/object:Gem::Version
|
147
98
|
version: 2.11.3
|
148
|
-
requirement: *id008
|
149
99
|
type: :development
|
150
|
-
- !ruby/object:Gem::Dependency
|
151
|
-
name: mocha
|
152
100
|
prerelease: false
|
153
|
-
version_requirements:
|
101
|
+
version_requirements: *2151903660
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: mocha
|
104
|
+
requirement: &2151919040 !ruby/object:Gem::Requirement
|
154
105
|
none: false
|
155
|
-
requirements:
|
156
|
-
- -
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
hash: 55
|
159
|
-
segments:
|
160
|
-
- 0
|
161
|
-
- 10
|
162
|
-
- 0
|
106
|
+
requirements:
|
107
|
+
- - =
|
108
|
+
- !ruby/object:Gem::Version
|
163
109
|
version: 0.10.0
|
164
|
-
requirement: *id009
|
165
110
|
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *2151919040
|
166
113
|
description: integrate the elastic search engine with rails
|
167
|
-
email:
|
114
|
+
email:
|
168
115
|
- ryan@codecrate.com
|
169
116
|
executables: []
|
170
|
-
|
171
117
|
extensions: []
|
172
|
-
|
173
118
|
extra_rdoc_files: []
|
174
|
-
|
175
|
-
files:
|
119
|
+
files:
|
176
120
|
- .document
|
177
121
|
- .gitignore
|
178
122
|
- .rvmrc
|
@@ -197,38 +141,35 @@ files:
|
|
197
141
|
- test/test_elastic_searchable.rb
|
198
142
|
homepage: http://github.com/socialcast/elastic_searchable
|
199
143
|
licenses: []
|
200
|
-
|
201
144
|
post_install_message:
|
202
145
|
rdoc_options: []
|
203
|
-
|
204
|
-
require_paths:
|
146
|
+
require_paths:
|
205
147
|
- lib
|
206
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
207
149
|
none: false
|
208
|
-
requirements:
|
209
|
-
- -
|
210
|
-
- !ruby/object:Gem::Version
|
211
|
-
|
212
|
-
segments:
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
segments:
|
213
155
|
- 0
|
214
|
-
|
215
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
hash: -2819836595351036726
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
158
|
none: false
|
217
|
-
requirements:
|
218
|
-
- -
|
219
|
-
- !ruby/object:Gem::Version
|
220
|
-
|
221
|
-
segments:
|
159
|
+
requirements:
|
160
|
+
- - ! '>='
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
segments:
|
222
164
|
- 0
|
223
|
-
|
165
|
+
hash: -2819836595351036726
|
224
166
|
requirements: []
|
225
|
-
|
226
167
|
rubyforge_project: elastic_searchable
|
227
|
-
rubygems_version: 1.8.
|
168
|
+
rubygems_version: 1.8.13
|
228
169
|
signing_key:
|
229
170
|
specification_version: 3
|
230
171
|
summary: elastic search for activerecord
|
231
|
-
test_files:
|
172
|
+
test_files:
|
232
173
|
- test/database.yml
|
233
174
|
- test/helper.rb
|
234
175
|
- test/setup_database.rb
|