acts_as_indexed 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/VERSION +1 -1
- data/acts_as_indexed.gemspec +2 -2
- data/lib/acts_as_indexed/class_methods.rb +36 -16
- data/lib/acts_as_indexed/configuration.rb +6 -0
- data/test/acts_as_indexed_test.rb +174 -94
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
===0.7.2 [31st March 2011]
|
2
|
+
- Fixed bug with ranking of records [Christopher Souvey - bug report]
|
3
|
+
- Fixed a bug with the slicing of records before AR order is applied. [Christopher Souvey - bug report]
|
4
|
+
- Fixed bug with slicing of id-only results.
|
5
|
+
- Error now raised when combining ids_only with find options other than limit and offset.
|
6
|
+
- Can now disable auto-indexing. Useful for large test suites.
|
7
|
+
|
1
8
|
===0.7.1 [22nd February 2011]
|
2
9
|
- Removed file locking on Microsoft Windows as it is unsupported.
|
3
10
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
data/acts_as_indexed.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts_as_indexed}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Douglas F Shearer"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-31}
|
13
13
|
s.description = %q{Acts As Indexed is a plugin which provides a pain-free way to add fulltext search to your Ruby on Rails app}
|
14
14
|
s.email = %q{dougal.s@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -58,6 +58,8 @@ module ActsAsIndexed
|
|
58
58
|
# Adds the passed +record+ to the index. Index is built if it does not already exist. Clears the query cache.
|
59
59
|
|
60
60
|
def index_add(record)
|
61
|
+
return if self.aai_config.disable_auto_indexing
|
62
|
+
|
61
63
|
build_index unless aai_config.index_file.directory?
|
62
64
|
index = new_index
|
63
65
|
index.add_record(record)
|
@@ -67,6 +69,8 @@ module ActsAsIndexed
|
|
67
69
|
# Removes the passed +record+ from the index. Clears the query cache.
|
68
70
|
|
69
71
|
def index_remove(record)
|
72
|
+
return if self.aai_config.disable_auto_indexing
|
73
|
+
|
70
74
|
index = new_index
|
71
75
|
index.remove_record(record)
|
72
76
|
@query_cache = {}
|
@@ -77,6 +81,8 @@ module ActsAsIndexed
|
|
77
81
|
# 2. Adds the new version to the index.
|
78
82
|
|
79
83
|
def index_update(record)
|
84
|
+
return if self.aai_config.disable_auto_indexing
|
85
|
+
|
80
86
|
build_index unless aai_config.index_file.directory?
|
81
87
|
index = new_index
|
82
88
|
index.update_record(record,find(record.id))
|
@@ -99,27 +105,40 @@ module ActsAsIndexed
|
|
99
105
|
# no_query_cache:: Turns off the query cache when set to true. Useful for testing.
|
100
106
|
|
101
107
|
def search_index(query, find_options={}, options={})
|
108
|
+
|
102
109
|
# Clear the query cache off if the key is set.
|
103
|
-
@query_cache = {} if
|
110
|
+
@query_cache = {} if options[:no_query_cache]
|
111
|
+
|
112
|
+
# Run the query if not already in cache.
|
104
113
|
if !@query_cache || !@query_cache[query]
|
105
|
-
logger.debug('Query not in cache, running search.')
|
106
114
|
build_index unless aai_config.index_file.directory?
|
107
|
-
|
108
|
-
(@query_cache ||= {})[query] = index.search(query)
|
109
|
-
else
|
110
|
-
logger.debug('Query held in cache.')
|
115
|
+
(@query_cache ||= {})[query] = new_index.search(query)
|
111
116
|
end
|
112
|
-
return @query_cache[query].sort.reverse.map{|r| r.first} if options[:ids_only] || @query_cache[query].empty?
|
113
117
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
+
if options[:ids_only]
|
119
|
+
find_option_keys = find_options.keys.map{ |k| k.to_sym }
|
120
|
+
find_option_keys -= [:limit, :offset]
|
121
|
+
if find_option_keys.any?
|
122
|
+
raise ArgumentError, 'ids_only can not be combined with find option keys other than :offset or :limit'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
if find_options.include?(:order)
|
127
|
+
part_query = @query_cache[query].map{ |r| r.first }
|
128
|
+
|
129
|
+
else
|
130
|
+
# slice up the results by offset and limit
|
131
|
+
offset = find_options[:offset] || 0
|
132
|
+
limit = find_options.include?(:limit) ? find_options[:limit] : @query_cache[query].size
|
133
|
+
part_query = @query_cache[query].sort_by{ |r| r.last }.slice(offset,limit).map{ |r| r.first }
|
134
|
+
|
135
|
+
# Set these to nil as we are dealing with the pagination by setting
|
136
|
+
# exactly what records we want.
|
137
|
+
find_options[:offset] = nil
|
138
|
+
find_options[:limit] = nil
|
139
|
+
end
|
118
140
|
|
119
|
-
|
120
|
-
# exactly what records we want.
|
121
|
-
find_options[:offset] = nil
|
122
|
-
find_options[:limit] = nil
|
141
|
+
return part_query if options[:ids_only]
|
123
142
|
|
124
143
|
with_scope :find => find_options do
|
125
144
|
# Doing the find like this eliminates the possibility of errors occuring
|
@@ -128,6 +147,7 @@ module ActsAsIndexed
|
|
128
147
|
|
129
148
|
if find_options.include?(:order)
|
130
149
|
records # Just return the records without ranking them.
|
150
|
+
|
131
151
|
else
|
132
152
|
# Results come back in random order from SQL, so order again.
|
133
153
|
ranked_records = {}
|
@@ -135,7 +155,7 @@ module ActsAsIndexed
|
|
135
155
|
ranked_records[r] = @query_cache[query][r.id]
|
136
156
|
end
|
137
157
|
|
138
|
-
ranked_records.to_a.sort_by{|a| a.last }.
|
158
|
+
ranked_records.to_a.sort_by{ |a| a.last }.map{ |r| r.first}
|
139
159
|
end
|
140
160
|
end
|
141
161
|
|
@@ -30,6 +30,11 @@ module ActsAsIndexed
|
|
30
30
|
# Set to true to enable.
|
31
31
|
# Default is false.
|
32
32
|
attr_accessor :case_sensitive
|
33
|
+
|
34
|
+
# Disable indexing, useful for large test suites.
|
35
|
+
# Set to false to disable.
|
36
|
+
# Default is false.
|
37
|
+
attr_accessor :disable_auto_indexing
|
33
38
|
|
34
39
|
def initialize
|
35
40
|
@index_file = nil
|
@@ -37,6 +42,7 @@ module ActsAsIndexed
|
|
37
42
|
@min_word_size = 3
|
38
43
|
@if_proc = if_proc
|
39
44
|
@case_sensitive = false
|
45
|
+
@disable_auto_indexing = false
|
40
46
|
end
|
41
47
|
|
42
48
|
# Since we cannot expect Rails to be available on load, it is best to put
|
@@ -15,135 +15,194 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
|
|
15
15
|
post = Post.new(:title => 'badger', :body => 'Thousands of them!')
|
16
16
|
assert post.save
|
17
17
|
assert_equal original_post_count + 1, Post.count
|
18
|
-
assert_equal [post.id],
|
18
|
+
assert_equal [post.id], find_with_index_ids('badger')
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def test_removes_from_index
|
22
22
|
original_post_count = Post.count
|
23
|
-
assert_equal [posts(:wikipedia_article_4).id],
|
23
|
+
assert_equal [posts(:wikipedia_article_4).id], find_with_index_ids('album')
|
24
24
|
assert Post.find(posts(:wikipedia_article_4).id).destroy
|
25
|
-
assert_equal [],
|
25
|
+
assert_equal [], find_with_index_ids('album')
|
26
26
|
assert_equal original_post_count - 1, Post.count
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def test_search_returns_posts
|
30
30
|
Post.with_query('album').each do |p|
|
31
31
|
assert_equal Post, p.class
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def test_search_returns_post_ids
|
36
|
-
|
36
|
+
find_with_index_ids('album').each do |pid|
|
37
37
|
assert p = Post.find(pid)
|
38
38
|
assert_equal Post, p.class
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
# After a portion of a record has been removed
|
43
43
|
# the portion removes should no longer be in the index.
|
44
44
|
def test_updates_index
|
45
45
|
p = Post.create(:title => 'A special title', :body => 'foo bar bla bla bla')
|
46
|
-
assert
|
46
|
+
assert find_with_index_ids('title').include?(p.id)
|
47
47
|
p.update_attributes(:title => 'No longer special')
|
48
|
-
assert !
|
48
|
+
assert !find_with_index_ids('title').include?(p.id)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def test_simple_queries
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
queries = {
|
53
|
+
nil => [],
|
54
|
+
'' => [],
|
55
|
+
'ship' => [5,6],
|
56
|
+
'crane' => [6,5],
|
57
|
+
'foo' => [6],
|
58
|
+
'foo ship' => [6],
|
59
|
+
'ship foo' => [6]
|
60
|
+
}
|
61
|
+
|
62
|
+
run_queries(queries)
|
63
|
+
end
|
64
|
+
|
60
65
|
def test_negative_queries
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
66
|
+
queries = {
|
67
|
+
'crane -foo' => [5],
|
68
|
+
'-foo crane' => [5],
|
69
|
+
'-foo' => [] # edgecase
|
70
|
+
}
|
71
|
+
|
72
|
+
run_queries(queries)
|
65
73
|
end
|
66
|
-
|
74
|
+
|
67
75
|
def test_quoted_queries
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
76
|
+
queries = {
|
77
|
+
'"crane ship"' => [5],
|
78
|
+
'"crane big"' => [6],
|
79
|
+
'foo "crane ship"' => [],
|
80
|
+
'"crane badger"' => []
|
81
|
+
}
|
82
|
+
|
83
|
+
run_queries(queries)
|
72
84
|
end
|
73
|
-
|
85
|
+
|
74
86
|
def test_negative_quoted_queries
|
75
|
-
|
76
|
-
|
87
|
+
queries = {
|
88
|
+
'crane -"crane ship"' => [6],
|
89
|
+
'-"crane big"' => [] # edgecase
|
90
|
+
}
|
91
|
+
|
92
|
+
run_queries(queries)
|
77
93
|
end
|
78
|
-
|
94
|
+
|
79
95
|
def test_scoped_negative_quoted_queries
|
80
|
-
|
81
|
-
|
96
|
+
queries = {
|
97
|
+
'crane -"crane ship"' => [6],
|
98
|
+
'-"crane big"' => []
|
99
|
+
}
|
100
|
+
|
101
|
+
run_queries(queries)
|
82
102
|
end
|
83
|
-
|
103
|
+
|
84
104
|
def test_start_queries
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
105
|
+
queries = {
|
106
|
+
'ship ^crane' => [5,6],
|
107
|
+
'^crane ship' => [5,6],
|
108
|
+
'^ship ^crane' => [5,6],
|
109
|
+
'^crane ^ship' => [5,6],
|
110
|
+
'^ship crane' => [5,6],
|
111
|
+
'crane ^ship' => [5,6],
|
112
|
+
'^crane' => [6,5] ,
|
113
|
+
'^cran' => [6,5],
|
114
|
+
'^cra' => [6,5],
|
115
|
+
'^cr' => [6,5,4],
|
116
|
+
'^c' => [5,2,1,6,3,4],
|
117
|
+
'^notthere' => []
|
118
|
+
}
|
119
|
+
|
120
|
+
run_queries(queries)
|
121
|
+
end
|
122
|
+
|
99
123
|
def test_start_quoted_queries
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
124
|
+
queries = {
|
125
|
+
'^"crane" ship' => [5,6],
|
126
|
+
'ship ^"crane"' => [5,6],
|
127
|
+
'^"crane ship"' => [5],
|
128
|
+
'^"crane shi"' => [5],
|
129
|
+
'^"crane sh"' => [5],
|
130
|
+
'^"crane s"' => [5],
|
131
|
+
'^"crane "' => [6,5],
|
132
|
+
'^"crane"' => [6,5],
|
133
|
+
'^"cran"' => [6,5],
|
134
|
+
'^"cra"' => [6,5],
|
135
|
+
'^"cr"' => [6,5,4],
|
136
|
+
'^"c"' => [5,2,1,6,3,4],
|
137
|
+
}
|
138
|
+
|
139
|
+
run_queries(queries)
|
140
|
+
end
|
141
|
+
|
114
142
|
def test_find_options
|
115
|
-
|
116
|
-
assert_equal
|
143
|
+
# limit.
|
144
|
+
assert_equal [6], Post.find_with_index('^cr', { :limit => 1 }, :ids_only => true)
|
145
|
+
assert_equal [6], Post.find_with_index('^cr', { :limit => 1 }).map{ |r| r.id }
|
146
|
+
|
147
|
+
# offset
|
148
|
+
assert_equal [5,4], Post.find_with_index('^cr', { :offset => 1 }, :ids_only => true)
|
149
|
+
assert_equal [5,4], Post.find_with_index('^cr', { :offset => 1 }).map{ |r| r.id }
|
150
|
+
|
151
|
+
# limit and offset
|
152
|
+
assert_equal [5], Post.find_with_index('^cr', { :limit => 1, :offset => 1 }, :ids_only => true)
|
153
|
+
assert_equal [5], Post.find_with_index('^cr', { :limit => 1, :offset => 1 }).map{ |r| r.id }
|
154
|
+
|
155
|
+
# order
|
156
|
+
assert_equal [6,5,4,3,2,1], Post.find_with_index('^c', { :order => 'id desc' }).map{ |r| r.id }
|
157
|
+
assert_equal [1,2,3,4,5,6], Post.find_with_index('^c', { :order => 'id' }).map{ |r| r.id }
|
158
|
+
|
159
|
+
# order and limit
|
160
|
+
assert_equal [6,5,4], Post.find_with_index('^c', { :order => 'id desc' , :limit => 3}).map{ |r| r.id }
|
161
|
+
assert_equal [1,2,3,4], Post.find_with_index('^c', { :order => 'id', :limit => 4 }).map{ |r| r.id }
|
162
|
+
|
163
|
+
# order and offset
|
164
|
+
assert_equal [5,4,3,2,1], Post.find_with_index('^c', { :order => 'id desc' , :offset => 1}).map{ |r| r.id }
|
165
|
+
assert_equal [3,4,5,6], Post.find_with_index('^c', { :order => 'id', :offset => 2 }).map{ |r| r.id }
|
166
|
+
|
167
|
+
# order, limit and offset
|
168
|
+
assert_equal [5,4,3], Post.find_with_index('^c', { :order => 'id desc' , :limit => 3, :offset => 1}).map{ |r| r.id }
|
169
|
+
assert_equal [3,4], Post.find_with_index('^c', { :order => 'id', :limit => 2, :offset => 2 }).map{ |r| r.id }
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_should_error_when_ids_only_combined_with_finder_options
|
173
|
+
expected_message = "ids_only can not be combined with find option keys other than :offset or :limit"
|
117
174
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
175
|
+
error = assert_raise(ArgumentError) do
|
176
|
+
Post.find_with_index('foo', { :order => 'id' }, :ids_only => true)
|
177
|
+
end
|
178
|
+
assert_equal(expected_message, error.message)
|
179
|
+
|
180
|
+
error = assert_raise(ArgumentError) do
|
181
|
+
Post.find_with_index('bar', { 'order' => 'id' }, :ids_only => true)
|
182
|
+
end
|
183
|
+
assert_equal(expected_message, error.message)
|
184
|
+
end
|
185
|
+
|
127
186
|
# When a atom already in a record is duplicated, it removes
|
128
187
|
# all records with that same atom from the index.
|
129
188
|
def test_update_record_bug
|
130
189
|
p = Post.find(6)
|
131
190
|
assert p.update_attributes(:body => p.body + ' crane')
|
132
|
-
assert_equal 2,
|
133
|
-
assert_equal 2,
|
191
|
+
assert_equal 2, find_with_index_ids('crane').size
|
192
|
+
assert_equal 2, find_with_index_ids('ship').size
|
134
193
|
end
|
135
|
-
|
194
|
+
|
136
195
|
# If an if proc is supplied, the index should only be created if the proc evaluated true
|
137
196
|
def test_create_if
|
138
197
|
Post.acts_as_indexed :fields => [:title, :body], :if => Proc.new { |post| post.visible }
|
139
|
-
|
198
|
+
|
140
199
|
original_post_count = Post.count
|
141
200
|
assert_equal [], Post.find_with_index('badger', {}, { :no_query_cache => true, :ids_only => true})
|
142
201
|
p = Post.new(:title => 'badger', :body => 'thousands of them!', :visible => true)
|
143
202
|
assert p.save
|
144
203
|
assert_equal original_post_count + 1, Post.count
|
145
204
|
assert_equal [p.id], Post.find_with_index('badger', {}, { :no_query_cache => true, :ids_only => true})
|
146
|
-
|
205
|
+
|
147
206
|
original_post_count = Post.count
|
148
207
|
assert_equal [], Post.find_with_index('unicorns')
|
149
208
|
p = Post.new(:title => 'unicorns', :body => 'there are none', :visible => false)
|
@@ -151,45 +210,45 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
|
|
151
210
|
assert_equal original_post_count + 1, Post.count
|
152
211
|
assert_equal [], Post.find_with_index('unicorns', {}, { :no_query_cache => true, :ids_only => true})
|
153
212
|
end
|
154
|
-
|
213
|
+
|
155
214
|
# If an index already exists, and an if proc is supplied, and the proc is true, it should still appear in the index
|
156
215
|
def test_update_if_update
|
157
216
|
Post.acts_as_indexed :fields => [:title, :body], :if => Proc.new { |post| post.visible }
|
158
217
|
destroy_index
|
159
|
-
|
218
|
+
|
160
219
|
assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
|
161
220
|
p = Post.find(6)
|
162
221
|
assert p.update_attributes(:visible => true)
|
163
222
|
assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
|
164
223
|
end
|
165
|
-
|
224
|
+
|
166
225
|
# If an index already exists, and an if proc is supplied, and the proc is false, it should no longer appear in the index
|
167
226
|
def test_update_if_remove
|
168
227
|
Post.acts_as_indexed :fields => [:title, :body], :if => Proc.new { |post| post.visible }
|
169
228
|
destroy_index
|
170
|
-
|
229
|
+
|
171
230
|
assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
|
172
231
|
p = Post.find(6)
|
173
232
|
assert p.update_attributes(:visible => false)
|
174
233
|
assert_equal 0, Post.find_with_index('crane',{},{ :no_query_cache => true, :ids_only => true}).size
|
175
234
|
end
|
176
|
-
|
235
|
+
|
177
236
|
# If an index doesn't exist, and an if proc is supplied, and the proc is true, it should appear in the index
|
178
237
|
def test_update_if_add
|
179
238
|
Post.acts_as_indexed :fields => [:title, :body], :if => Proc.new { |post| post.visible }
|
180
239
|
destroy_index
|
181
|
-
|
240
|
+
|
182
241
|
assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
|
183
242
|
p = Post.find(5)
|
184
243
|
assert p.update_attributes(:visible => true)
|
185
244
|
assert_equal 2, Post.find_with_index('crane',{},{ :no_query_cache => true, :ids_only => true}).size
|
186
245
|
end
|
187
|
-
|
246
|
+
|
188
247
|
# If an index doesn't exist, and an if proc is supplied, and the proc is false, then nothing happens
|
189
248
|
def test_update_if_not_in
|
190
249
|
Post.acts_as_indexed :fields => [:title, :body], :if => Proc.new { |post| post.visible }
|
191
250
|
destroy_index
|
192
|
-
|
251
|
+
|
193
252
|
assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size
|
194
253
|
p = Post.find(5)
|
195
254
|
assert p.update_attributes(:visible => false)
|
@@ -199,22 +258,43 @@ class ActsAsIndexedTest < ActiveSupport::TestCase
|
|
199
258
|
def test_case_insensitive
|
200
259
|
Post.acts_as_indexed :fields => [:title, :body], :case_sensitive => true
|
201
260
|
destroy_index
|
202
|
-
|
261
|
+
|
203
262
|
assert_equal 1, Post.find_with_index('Ellis', {}, { :no_query_cache => true, :ids_only => true}).size
|
204
263
|
assert_equal 0, Post.find_with_index('ellis', {}, { :no_query_cache => true, :ids_only => true}).size
|
205
|
-
|
264
|
+
|
206
265
|
assert_equal 3, Post.find_with_index('The', {}, { :no_query_cache => true, :ids_only => true}).size
|
207
266
|
assert_equal 5, Post.find_with_index('the', {}, { :no_query_cache => true, :ids_only => true}).size
|
208
267
|
end
|
209
268
|
|
210
269
|
private
|
211
|
-
|
212
|
-
def
|
213
|
-
|
270
|
+
|
271
|
+
def run_queries(queries)
|
272
|
+
queries.each do |query, expected_results|
|
273
|
+
|
274
|
+
actual_results = find_with_index_ids(query)
|
275
|
+
message = "#{expected_results.inspect} expected for find_with_index(#{query.inspect}) but was\n#{actual_results.inspect}"
|
276
|
+
assert expected_results == actual_results, message
|
277
|
+
|
278
|
+
actual_results = find_with_index_ids_only(query)
|
279
|
+
message = "#{expected_results.inspect} expected for find_with_index(#{query.inspect}, {}, :ids_only => true) but was\n#{actual_results.inspect}"
|
280
|
+
assert expected_results == actual_results, message
|
281
|
+
|
282
|
+
actual_results = find_with_query(query)
|
283
|
+
message = "#{expected_results.inspect} expected for with_query(#{query.inspect}) but was\n#{actual_results.inspect}"
|
284
|
+
assert expected_results.sort == actual_results.sort, message
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def find_with_index_ids(query)
|
289
|
+
Post.find_with_index(query).map { |r| r.id }
|
214
290
|
end
|
215
291
|
|
216
|
-
def
|
217
|
-
|
292
|
+
def find_with_index_ids_only(query)
|
293
|
+
Post.find_with_index(query, {}, :ids_only => true)
|
294
|
+
end
|
295
|
+
|
296
|
+
def find_with_query(query)
|
297
|
+
Post.with_query(query).map { |r| r.id }
|
218
298
|
end
|
219
299
|
|
220
300
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_indexed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Douglas F Shearer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-31 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|