sunspot 2.0.0.pre.120417 → 2.0.0.pre.120720
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/.gitignore +2 -0
- data/History.txt +2 -0
- data/lib/sunspot/adapters.rb +5 -1
- data/lib/sunspot/dsl/field_query.rb +1 -7
- data/lib/sunspot/dsl/query_facet.rb +3 -3
- data/lib/sunspot/field.rb +1 -1
- data/lib/sunspot/query/query_facet.rb +37 -0
- data/lib/sunspot/query/restriction.rb +34 -0
- data/lib/sunspot/search/field_group.rb +11 -3
- data/lib/sunspot/version.rb +1 -1
- data/spec/api/query/connectives_examples.rb +5 -5
- data/spec/api/query/dynamic_fields_examples.rb +1 -1
- data/spec/api/query/faceting_examples.rb +52 -11
- data/spec/api/query/fulltext_examples.rb +2 -2
- data/spec/api/query/scope_examples.rb +5 -5
- data/spec/integration/faceting_spec.rb +60 -14
- data/spec/integration/field_grouping_spec.rb +26 -0
- data/spec/integration/scoped_search_spec.rb +35 -3
- metadata +7 -18
data/.gitignore
CHANGED
data/History.txt
CHANGED
@@ -12,6 +12,8 @@
|
|
12
12
|
* Adds `Retry5xxSessionProxy` to retry requests when an internal server error
|
13
13
|
occurs (Nick Zadrozny)
|
14
14
|
* Adds support for range queries (Jan Ulrich)
|
15
|
+
* Allows custom field names specified with :as to be symbols (David Oliver)
|
16
|
+
* Add field exclusion when faceting (Cuong Hoang)
|
15
17
|
|
16
18
|
== 1.3.0 2011-11-26
|
17
19
|
* Requests to Solr use HTTP POST verb by default to avoid issues when the query string grows too large for GET (Johan Van Ryseghem)
|
data/lib/sunspot/adapters.rb
CHANGED
@@ -79,7 +79,11 @@ module Sunspot
|
|
79
79
|
# wraps the given instance
|
80
80
|
#
|
81
81
|
def adapt(instance) #:nodoc:
|
82
|
-
|
82
|
+
@known_adapters ||= {}
|
83
|
+
clazz = instance.class
|
84
|
+
adapter = @known_adapters[clazz.name.to_sym] || self.for(clazz)
|
85
|
+
@known_adapters[clazz.name.to_sym] ||= adapter
|
86
|
+
adapter.new(instance)
|
83
87
|
end
|
84
88
|
|
85
89
|
# Register an instance adapter for a set of classes. When searching for
|
@@ -249,15 +249,9 @@ module Sunspot
|
|
249
249
|
"wrong number of arguments (#{field_names.length} for 1)"
|
250
250
|
)
|
251
251
|
end
|
252
|
-
if options.has_key?(:exclude)
|
253
|
-
raise(
|
254
|
-
ArgumentError,
|
255
|
-
"can't use :exclude with query facets"
|
256
|
-
)
|
257
|
-
end
|
258
252
|
search_facet = @search.add_query_facet(field_names.first, options)
|
259
253
|
Sunspot::Util.instance_eval_or_call(
|
260
|
-
QueryFacet.new(@query, @setup, search_facet),
|
254
|
+
QueryFacet.new(@query, @setup, search_facet, options),
|
261
255
|
&block
|
262
256
|
)
|
263
257
|
elsif options[:only]
|
@@ -5,8 +5,8 @@ module Sunspot
|
|
5
5
|
# method.
|
6
6
|
#
|
7
7
|
class QueryFacet
|
8
|
-
def initialize(query, setup, facet) #:nodoc:
|
9
|
-
@query, @setup, @facet = query, setup, facet
|
8
|
+
def initialize(query, setup, facet, options) #:nodoc:
|
9
|
+
@query, @setup, @facet, @options = query, setup, facet, options
|
10
10
|
end
|
11
11
|
|
12
12
|
#
|
@@ -24,7 +24,7 @@ module Sunspot
|
|
24
24
|
# An object used to identify this facet row in the results.
|
25
25
|
#
|
26
26
|
def row(label, &block)
|
27
|
-
query_facet = Sunspot::Query::QueryFacet.new
|
27
|
+
query_facet = Sunspot::Query::QueryFacet.new(@options)
|
28
28
|
Sunspot::Util.instance_eval_or_call(
|
29
29
|
Scope.new(@query.add_query_facet(query_facet), @setup),
|
30
30
|
&block
|
data/lib/sunspot/field.rb
CHANGED
@@ -104,7 +104,7 @@ module Sunspot
|
|
104
104
|
def set_indexed_name(options)
|
105
105
|
@indexed_name =
|
106
106
|
if options[:as]
|
107
|
-
options.delete(:as)
|
107
|
+
options.delete(:as).to_s
|
108
108
|
else
|
109
109
|
"#{@type.indexed_name(@name).to_s}#{'m' if @multiple }#{'s' if @stored}#{'v' if more_like_this?}"
|
110
110
|
end
|
@@ -1,6 +1,17 @@
|
|
1
1
|
module Sunspot
|
2
2
|
module Query
|
3
3
|
class QueryFacet < Connective::Conjunction
|
4
|
+
|
5
|
+
def initialize(options = {}, negated = false)
|
6
|
+
if exclude_filters = options[:exclude]
|
7
|
+
@exclude_tag = Util.Array(exclude_filters).map do |filter|
|
8
|
+
filter.tag
|
9
|
+
end.join(',')
|
10
|
+
end
|
11
|
+
super(negated)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
4
15
|
def to_params
|
5
16
|
if @components.empty?
|
6
17
|
{}
|
@@ -11,6 +22,32 @@ module Sunspot
|
|
11
22
|
}
|
12
23
|
end
|
13
24
|
end
|
25
|
+
|
26
|
+
def to_boolean_phrase
|
27
|
+
"#{to_local_params}#{super}"
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def local_params
|
33
|
+
@local_params ||=
|
34
|
+
begin
|
35
|
+
local_params = {}
|
36
|
+
local_params[:ex] = @exclude_tag if @exclude_tag
|
37
|
+
local_params
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_local_params
|
42
|
+
if local_params.empty?
|
43
|
+
''
|
44
|
+
else
|
45
|
+
pairs = local_params.map do |key, value|
|
46
|
+
"#{key}=#{value}"
|
47
|
+
end
|
48
|
+
"{!#{pairs.join(' ')}}"
|
49
|
+
end
|
50
|
+
end
|
14
51
|
end
|
15
52
|
end
|
16
53
|
end
|
@@ -184,6 +184,23 @@ module Sunspot
|
|
184
184
|
solr_value
|
185
185
|
end
|
186
186
|
|
187
|
+
def to_solr_conditional
|
188
|
+
"{* TO #{solr_value}}"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
#
|
193
|
+
# Results must have field with value less or equal to than given value
|
194
|
+
#
|
195
|
+
class LessThanOrEqualTo < Base
|
196
|
+
private
|
197
|
+
|
198
|
+
def solr_value(value = @value)
|
199
|
+
solr_value = super
|
200
|
+
solr_value = "\"#{solr_value}\"" if solr_value.index(' ')
|
201
|
+
solr_value
|
202
|
+
end
|
203
|
+
|
187
204
|
def to_solr_conditional
|
188
205
|
"[* TO #{solr_value}]"
|
189
206
|
end
|
@@ -201,6 +218,23 @@ module Sunspot
|
|
201
218
|
solr_value
|
202
219
|
end
|
203
220
|
|
221
|
+
def to_solr_conditional
|
222
|
+
"{#{solr_value} TO *}"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
#
|
227
|
+
# Results must have field with value greater than or equal to given value
|
228
|
+
#
|
229
|
+
class GreaterThanOrEqualTo < Base
|
230
|
+
private
|
231
|
+
|
232
|
+
def solr_value(value = @value)
|
233
|
+
solr_value = super
|
234
|
+
solr_value = "\"#{solr_value}\"" if solr_value.index(' ')
|
235
|
+
solr_value
|
236
|
+
end
|
237
|
+
|
204
238
|
def to_solr_conditional
|
205
239
|
"[#{solr_value} TO *]"
|
206
240
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'sunspot/search/paginated_collection'
|
2
|
+
|
1
3
|
module Sunspot
|
2
4
|
module Search
|
3
5
|
class FieldGroup
|
@@ -9,9 +11,11 @@ module Sunspot
|
|
9
11
|
@groups ||=
|
10
12
|
begin
|
11
13
|
if solr_response
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
paginate_collection(
|
15
|
+
solr_response['groups'].map do |group|
|
16
|
+
Group.new(group['groupValue'], group['doclist'], @search)
|
17
|
+
end
|
18
|
+
)
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
@@ -33,6 +37,10 @@ module Sunspot
|
|
33
37
|
def solr_response
|
34
38
|
@search.group_response[@field.indexed_name.to_s]
|
35
39
|
end
|
40
|
+
|
41
|
+
def paginate_collection(collection)
|
42
|
+
PaginatedCollection.new(collection, @search.query.page, @search.query.per_page, total)
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
data/lib/sunspot/version.rb
CHANGED
@@ -23,7 +23,7 @@ shared_examples_for "query with connective scope" do
|
|
23
23
|
end
|
24
24
|
connection.should have_last_search_including(
|
25
25
|
:fq,
|
26
|
-
'(blog_id_i:2 OR (category_ids_im:1 AND average_rating_ft:
|
26
|
+
'(blog_id_i:2 OR (category_ids_im:1 AND average_rating_ft:{3\.0 TO *}))'
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
@@ -38,7 +38,7 @@ shared_examples_for "query with connective scope" do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
connection.should have_last_search_including(
|
41
|
-
:fq, '(category_ids_im:1 OR (-average_rating_ft:
|
41
|
+
:fq, '(category_ids_im:1 OR (-average_rating_ft:{3\.0 TO *} AND blog_id_i:1))'
|
42
42
|
)
|
43
43
|
end
|
44
44
|
|
@@ -62,7 +62,7 @@ shared_examples_for "query with connective scope" do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
connection.should have_last_search_including(
|
65
|
-
:fq, '-(-category_ids_im:1 AND average_rating_ft:
|
65
|
+
:fq, '-(-category_ids_im:1 AND average_rating_ft:{3\.0 TO *})'
|
66
66
|
)
|
67
67
|
end
|
68
68
|
|
@@ -149,7 +149,7 @@ shared_examples_for "query with connective scope" do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
connection.should have_last_search_including(
|
152
|
-
:fq, '-(average_rating_ft:[* TO *] AND -average_rating_ft:
|
152
|
+
:fq, '-(average_rating_ft:[* TO *] AND -average_rating_ft:{3\.0 TO *})'
|
153
153
|
)
|
154
154
|
end
|
155
155
|
|
@@ -162,7 +162,7 @@ shared_examples_for "query with connective scope" do
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
connection.should have_last_search_including(
|
165
|
-
:fq, "(id:(Post\\ #{post.id}) OR average_rating_ft:
|
165
|
+
:fq, "(id:(Post\\ #{post.id}) OR average_rating_ft:{3\\.0 TO *})"
|
166
166
|
)
|
167
167
|
end
|
168
168
|
|
@@ -14,7 +14,7 @@ shared_examples_for "query with dynamic field support" do
|
|
14
14
|
with(:test).less_than(1)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
connection.should have_last_search_including(:fq, 'custom_integer\:test_i:
|
17
|
+
connection.should have_last_search_including(:fq, 'custom_integer\:test_i:{* TO 1}')
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'restricts by dynamic float field with between restriction' do
|
@@ -179,17 +179,6 @@ shared_examples_for "facetable query" do
|
|
179
179
|
connection.should have_last_search_with(:"f.blog.facet.sort" => 'true')
|
180
180
|
end
|
181
181
|
|
182
|
-
it 'raises an ArgumentError if exclusion attempted on a query facet' do
|
183
|
-
lambda do
|
184
|
-
search do
|
185
|
-
blog_filter = with(:blog_id, 1)
|
186
|
-
facet(:bad, :exclude => blog_filter) do
|
187
|
-
row(:bogus) { with(:blog_id, 1) }
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end.should raise_error(ArgumentError)
|
191
|
-
end
|
192
|
-
|
193
182
|
it 'raises an ArgumentError if exclusion attempted on a restricted field facet' do
|
194
183
|
lambda do
|
195
184
|
search do
|
@@ -426,6 +415,58 @@ shared_examples_for "facetable query" do
|
|
426
415
|
connection.searches.last[:"facet.query"].should be_a(String)
|
427
416
|
end
|
428
417
|
|
418
|
+
it 'tags and excludes a scope filter in a query facet' do
|
419
|
+
search do
|
420
|
+
blog_filter = with(:blog_id, 1)
|
421
|
+
facet:foo, :exclude => blog_filter do
|
422
|
+
row(:bar) do
|
423
|
+
with(:category_ids, 1)
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
filter_tag = get_filter_tag('blog_id_i:1')
|
428
|
+
connection.should have_last_search_with(
|
429
|
+
:"facet.query" => "{!ex=#{filter_tag}}category_ids_im:1"
|
430
|
+
)
|
431
|
+
end
|
432
|
+
|
433
|
+
it 'tags and excludes a disjunction filter in a query facet' do
|
434
|
+
search do
|
435
|
+
blog_filter = any_of do
|
436
|
+
with(:blog_id, 1)
|
437
|
+
with(:blog_id, 2)
|
438
|
+
end
|
439
|
+
facet:foo, :exclude => blog_filter do
|
440
|
+
row(:bar) do
|
441
|
+
with(:category_ids, 1)
|
442
|
+
end
|
443
|
+
end
|
444
|
+
end
|
445
|
+
filter_tag = get_filter_tag('(blog_id_i:1 OR blog_id_i:2)')
|
446
|
+
connection.should have_last_search_with(
|
447
|
+
:"facet.query" => "{!ex=#{filter_tag}}category_ids_im:1"
|
448
|
+
)
|
449
|
+
end
|
450
|
+
|
451
|
+
it 'tags and excludes multiple filters in a query facet' do
|
452
|
+
search do
|
453
|
+
blog_filter = with(:blog_id, 1)
|
454
|
+
category_filter = with(:category_ids, 2)
|
455
|
+
facet:foo, :exclude => [blog_filter, category_filter] do
|
456
|
+
row(:bar) do
|
457
|
+
with(:category_ids, 1)
|
458
|
+
end
|
459
|
+
end
|
460
|
+
end
|
461
|
+
filter_tags = %w(blog_id_i:1 category_ids_im:2).map do |phrase|
|
462
|
+
get_filter_tag(phrase)
|
463
|
+
end.join(',')
|
464
|
+
connection.should have_last_search_with(
|
465
|
+
:"facet.query" => "{!ex=#{filter_tags}}category_ids_im:1"
|
466
|
+
)
|
467
|
+
end
|
468
|
+
|
469
|
+
|
429
470
|
it 'ignores facet query with only empty rows' do
|
430
471
|
search do
|
431
472
|
facet :foo do
|
@@ -224,7 +224,7 @@ shared_examples_for 'fulltext query' do
|
|
224
224
|
end
|
225
225
|
end
|
226
226
|
end
|
227
|
-
connection.should have_last_search_with(:bq => ['average_rating_ft:
|
227
|
+
connection.should have_last_search_with(:bq => ['average_rating_ft:{2\.0 TO *}^2.0'])
|
228
228
|
end
|
229
229
|
|
230
230
|
it 'creates multiple boost queries' do
|
@@ -240,7 +240,7 @@ shared_examples_for 'fulltext query' do
|
|
240
240
|
end
|
241
241
|
connection.should have_last_search_with(
|
242
242
|
:bq => [
|
243
|
-
'average_rating_ft:
|
243
|
+
'average_rating_ft:{2\.0 TO *}^2.0',
|
244
244
|
'featured_bs:true^1.5'
|
245
245
|
]
|
246
246
|
)
|
@@ -46,21 +46,21 @@ shared_examples_for "scoped query" do
|
|
46
46
|
search do
|
47
47
|
with(:average_rating).less_than 3.0
|
48
48
|
end
|
49
|
-
connection.should have_last_search_including(:fq, 'average_rating_ft:
|
49
|
+
connection.should have_last_search_including(:fq, 'average_rating_ft:{* TO 3\.0}')
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'should quote string with space in a less than match' do
|
53
53
|
search do
|
54
54
|
with(:title).less_than('test value')
|
55
55
|
end
|
56
|
-
connection.should have_last_search_including(:fq, 'title_ss:
|
56
|
+
connection.should have_last_search_including(:fq, 'title_ss:{* TO "test\ value"}')
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'scopes by greater than match with float' do
|
60
60
|
search do
|
61
61
|
with(:average_rating).greater_than 3.0
|
62
62
|
end
|
63
|
-
connection.should have_last_search_including(:fq, 'average_rating_ft:
|
63
|
+
connection.should have_last_search_including(:fq, 'average_rating_ft:{3\.0 TO *}')
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'scopes by short-form between match with integers' do
|
@@ -116,14 +116,14 @@ shared_examples_for "scoped query" do
|
|
116
116
|
search do
|
117
117
|
without(:average_rating).less_than 3.0
|
118
118
|
end
|
119
|
-
connection.should have_last_search_including(:fq, '-average_rating_ft:
|
119
|
+
connection.should have_last_search_including(:fq, '-average_rating_ft:{* TO 3\.0}')
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'scopes by not greater than match with float' do
|
123
123
|
search do
|
124
124
|
without(:average_rating).greater_than 3.0
|
125
125
|
end
|
126
|
-
connection.should have_last_search_including(:fq, '-average_rating_ft:
|
126
|
+
connection.should have_last_search_including(:fq, '-average_rating_ft:{3\.0 TO *}')
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'scopes by not between match with shorthand' do
|
@@ -166,24 +166,70 @@ describe 'search faceting' do
|
|
166
166
|
)
|
167
167
|
end
|
168
168
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
169
|
+
context 'field faceting' do
|
170
|
+
it 'should exclude filter from faceting' do
|
171
|
+
search = Sunspot.search(Post) do
|
172
|
+
with(:blog_id, 1)
|
173
|
+
category_filter = with(:category_ids, 1)
|
174
|
+
facet(:category_ids, :exclude => category_filter)
|
175
|
+
end
|
176
|
+
search.facet(:category_ids).rows.map { |row| row.value }.to_set.should == Set[1, 2]
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should use facet keys to facet more than once with different exclusions' do
|
180
|
+
search = Sunspot.search(Post) do
|
181
|
+
with(:blog_id, 1)
|
182
|
+
category_filter = with(:category_ids, 1)
|
183
|
+
facet(:category_ids)
|
184
|
+
facet(:category_ids, :exclude => category_filter, :name => :all_category_ids)
|
185
|
+
end
|
186
|
+
search.facet(:category_ids).rows.map { |row| row.value }.should == [1]
|
187
|
+
search.facet(:all_category_ids).rows.map { |row| row.value }.to_set.should == Set[1, 2]
|
174
188
|
end
|
175
|
-
search.facet(:category_ids).rows.map { |row| row.value }.to_set.should == Set[1, 2]
|
176
189
|
end
|
177
190
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
191
|
+
context 'query faceting' do
|
192
|
+
it 'should exclude filter from faceting' do
|
193
|
+
search = Sunspot.search(Post) do
|
194
|
+
with(:blog_id, 1)
|
195
|
+
category_filter = with(:category_ids, 1)
|
196
|
+
facet :category_ids, :exclude => category_filter do
|
197
|
+
row(:category_1) do
|
198
|
+
with(:category_ids, 1)
|
199
|
+
end
|
200
|
+
row(:category_2) do
|
201
|
+
with(:category_ids, 2)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
search.facet(:category_ids).rows.map { |row| [row.value, row.count] }.to_set.should == Set[[:category_1, 1], [:category_2, 1]]
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should use facet keys to facet more than once with different exclusions' do
|
209
|
+
search = Sunspot.search(Post) do
|
210
|
+
with(:blog_id, 1)
|
211
|
+
category_filter = with(:category_ids, 1)
|
212
|
+
facet :category_ids do
|
213
|
+
row(:category_1) do
|
214
|
+
with(:category_ids, 1)
|
215
|
+
end
|
216
|
+
row(:category_2) do
|
217
|
+
with(:category_ids, 2)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
facet :all_category_ids, :exclude => category_filter do
|
222
|
+
row(:category_1) do
|
223
|
+
with(:category_ids, 1)
|
224
|
+
end
|
225
|
+
row(:category_2) do
|
226
|
+
with(:category_ids, 2)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
search.facet(:category_ids).rows.map { |row| [row.value, row.count] }.to_set.should == Set[[:category_1, 1]]
|
231
|
+
search.facet(:all_category_ids).rows.map { |row| [row.value, row.count] }.to_set.should == Set[[:category_1, 1], [:category_2, 1]]
|
184
232
|
end
|
185
|
-
search.facet(:category_ids).rows.map { |row| row.value }.should == [1]
|
186
|
-
search.facet(:all_category_ids).rows.map { |row| row.value }.to_set.should == Set[1, 2]
|
187
233
|
end
|
188
234
|
end
|
189
235
|
|
@@ -71,4 +71,30 @@ describe "field grouping" do
|
|
71
71
|
title1_group = search.group(:title).groups.detect { |g| g.value == "Title1" }
|
72
72
|
title1_group.hits.first.primary_key.to_i.should == highest_ranked_post.id
|
73
73
|
end
|
74
|
+
|
75
|
+
it "allows pagination within groups" do
|
76
|
+
search = Sunspot.search(Post) do
|
77
|
+
group :title
|
78
|
+
paginate :per_page => 1, :page => 2
|
79
|
+
end
|
80
|
+
|
81
|
+
search.group(:title).groups.length.should eql(1)
|
82
|
+
search.group(:title).groups.first.results.should == [ @posts.last ]
|
83
|
+
end
|
84
|
+
|
85
|
+
context "returns a paginated collection" do
|
86
|
+
subject do
|
87
|
+
search = Sunspot.search(Post) do
|
88
|
+
group :title
|
89
|
+
paginate :per_page => 1, :page => 2
|
90
|
+
end
|
91
|
+
search.group(:title).groups
|
92
|
+
end
|
93
|
+
|
94
|
+
it { subject.per_page.should eql(1) }
|
95
|
+
it { subject.total_pages.should eql(2) }
|
96
|
+
it { subject.current_page.should eql(2) }
|
97
|
+
it { subject.first_page?.should be_false }
|
98
|
+
it { subject.last_page?.should be_true }
|
99
|
+
end
|
74
100
|
end
|
@@ -33,24 +33,48 @@ describe 'scoped_search' do
|
|
33
33
|
|
34
34
|
it 'should filter by less than' do
|
35
35
|
results = Sunspot.search(clazz) { with(field).less_than values[2] }.results
|
36
|
-
(0..
|
37
|
-
(
|
36
|
+
(0..1).each { |i| results.should include(@objects[i]) }
|
37
|
+
(2..4).each { |i| results.should_not include(@objects[i]) }
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should reject by less than' do
|
41
41
|
results = Sunspot.search(clazz) { without(field).less_than values[2] }.results
|
42
|
+
(0..1).each { |i| results.should_not include(@objects[i]) }
|
43
|
+
(2..4).each { |i| results.should include(@objects[i]) }
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should filter by less than or equal to' do
|
47
|
+
results = Sunspot.search(clazz) { with(field).less_than_or_equal_to values[2] }.results
|
48
|
+
(0..2).each { |i| results.should include(@objects[i]) }
|
49
|
+
(3..4).each { |i| results.should_not include(@objects[i]) }
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should reject by less than or equal to' do
|
53
|
+
results = Sunspot.search(clazz) { without(field).less_than_or_equal_to values[2] }.results
|
42
54
|
(0..2).each { |i| results.should_not include(@objects[i]) }
|
43
55
|
(3..4).each { |i| results.should include(@objects[i]) }
|
44
56
|
end
|
45
57
|
|
46
58
|
it 'should filter by greater than' do
|
47
59
|
results = Sunspot.search(clazz) { with(field).greater_than values[2] }.results
|
60
|
+
(3..4).each { |i| results.should include(@objects[i]) }
|
61
|
+
(0..2).each { |i| results.should_not include(@objects[i]) }
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should reject by greater than' do
|
65
|
+
results = Sunspot.search(clazz) { without(field).greater_than values[2] }.results
|
66
|
+
(3..4).each { |i| results.should_not include(@objects[i]) }
|
67
|
+
(0..2).each { |i| results.should include(@objects[i]) }
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should filter by greater than or equal to' do
|
71
|
+
results = Sunspot.search(clazz) { with(field).greater_than_or_equal_to values[2] }.results
|
48
72
|
(2..4).each { |i| results.should include(@objects[i]) }
|
49
73
|
(0..1).each { |i| results.should_not include(@objects[i]) }
|
50
74
|
end
|
51
75
|
|
52
76
|
it 'should reject by greater than' do
|
53
|
-
results = Sunspot.search(clazz) { without(field).
|
77
|
+
results = Sunspot.search(clazz) { without(field).greater_than_or_equal_to values[2] }.results
|
54
78
|
(2..4).each { |i| results.should_not include(@objects[i]) }
|
55
79
|
(0..1).each { |i| results.should include(@objects[i]) }
|
56
80
|
end
|
@@ -119,6 +143,14 @@ describe 'scoped_search' do
|
|
119
143
|
end
|
120
144
|
end
|
121
145
|
|
146
|
+
describe 'Legacy (static) fields' do
|
147
|
+
it "allows for using symbols in defining static field names" do
|
148
|
+
Sunspot.remove_all
|
149
|
+
Sunspot.index!(legacy = Post.new(:title => "foo"))
|
150
|
+
Sunspot.search(Post) { with(:legacy, "legacy foo") }.results.should == [legacy]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
122
154
|
describe 'reserved words' do
|
123
155
|
%w(AND OR NOT TO).each do |word|
|
124
156
|
it "should successfully search for #{word.inspect}" do
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: 6
|
4
|
+
prerelease: true
|
6
5
|
segments:
|
7
6
|
- 2
|
8
7
|
- 0
|
9
8
|
- 0
|
10
9
|
- pre
|
11
|
-
-
|
12
|
-
version: 2.0.0.pre.
|
10
|
+
- 120720
|
11
|
+
version: 2.0.0.pre.120720
|
13
12
|
platform: ruby
|
14
13
|
authors:
|
15
14
|
- Mat Brown
|
@@ -35,17 +34,16 @@ autorequire:
|
|
35
34
|
bindir: bin
|
36
35
|
cert_chain: []
|
37
36
|
|
38
|
-
date: 2012-
|
37
|
+
date: 2012-07-20 00:00:00 -07:00
|
38
|
+
default_executable:
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rsolr
|
42
42
|
prerelease: false
|
43
43
|
requirement: &id001 !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
44
|
requirements:
|
46
45
|
- - ~>
|
47
46
|
- !ruby/object:Gem::Version
|
48
|
-
hash: 25
|
49
47
|
segments:
|
50
48
|
- 1
|
51
49
|
- 0
|
@@ -57,11 +55,9 @@ dependencies:
|
|
57
55
|
name: pr_geohash
|
58
56
|
prerelease: false
|
59
57
|
requirement: &id002 !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
58
|
requirements:
|
62
59
|
- - ~>
|
63
60
|
- !ruby/object:Gem::Version
|
64
|
-
hash: 15
|
65
61
|
segments:
|
66
62
|
- 1
|
67
63
|
- 0
|
@@ -72,11 +68,9 @@ dependencies:
|
|
72
68
|
name: rspec
|
73
69
|
prerelease: false
|
74
70
|
requirement: &id003 !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
71
|
requirements:
|
77
72
|
- - ~>
|
78
73
|
- !ruby/object:Gem::Version
|
79
|
-
hash: 23
|
80
74
|
segments:
|
81
75
|
- 2
|
82
76
|
- 6
|
@@ -88,11 +82,9 @@ dependencies:
|
|
88
82
|
name: hanna
|
89
83
|
prerelease: false
|
90
84
|
requirement: &id004 !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
85
|
requirements:
|
93
86
|
- - ">="
|
94
87
|
- !ruby/object:Gem::Version
|
95
|
-
hash: 3
|
96
88
|
segments:
|
97
89
|
- 0
|
98
90
|
version: "0"
|
@@ -288,6 +280,7 @@ files:
|
|
288
280
|
- tasks/rdoc.rake
|
289
281
|
- tasks/schema.rake
|
290
282
|
- tasks/todo.rake
|
283
|
+
has_rdoc: true
|
291
284
|
homepage: http://outoftime.github.com/sunspot
|
292
285
|
licenses: []
|
293
286
|
|
@@ -301,20 +294,16 @@ rdoc_options:
|
|
301
294
|
require_paths:
|
302
295
|
- lib
|
303
296
|
required_ruby_version: !ruby/object:Gem::Requirement
|
304
|
-
none: false
|
305
297
|
requirements:
|
306
298
|
- - ">="
|
307
299
|
- !ruby/object:Gem::Version
|
308
|
-
hash: 3
|
309
300
|
segments:
|
310
301
|
- 0
|
311
302
|
version: "0"
|
312
303
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
313
|
-
none: false
|
314
304
|
requirements:
|
315
305
|
- - ">"
|
316
306
|
- !ruby/object:Gem::Version
|
317
|
-
hash: 25
|
318
307
|
segments:
|
319
308
|
- 1
|
320
309
|
- 3
|
@@ -323,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
323
312
|
requirements: []
|
324
313
|
|
325
314
|
rubyforge_project: sunspot
|
326
|
-
rubygems_version: 1.
|
315
|
+
rubygems_version: 1.3.6
|
327
316
|
signing_key:
|
328
317
|
specification_version: 3
|
329
318
|
summary: Library for expressive, powerful interaction with the Solr search engine
|