sunspot 2.0.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/Appraisals +7 -0
- data/Gemfile +0 -2
- data/History.txt +10 -0
- data/lib/sunspot.rb +55 -17
- data/lib/sunspot/adapters.rb +68 -18
- data/lib/sunspot/batcher.rb +1 -1
- data/lib/sunspot/configuration.rb +4 -2
- data/lib/sunspot/data_extractor.rb +36 -6
- data/lib/sunspot/dsl.rb +4 -3
- data/lib/sunspot/dsl/adjustable.rb +2 -2
- data/lib/sunspot/dsl/field_query.rb +69 -16
- data/lib/sunspot/dsl/field_stats.rb +25 -0
- data/lib/sunspot/dsl/fields.rb +28 -8
- data/lib/sunspot/dsl/fulltext.rb +9 -1
- data/lib/sunspot/dsl/group.rb +118 -0
- data/lib/sunspot/dsl/paginatable.rb +4 -1
- data/lib/sunspot/dsl/scope.rb +19 -10
- data/lib/sunspot/dsl/search.rb +1 -1
- data/lib/sunspot/dsl/spellcheckable.rb +14 -0
- data/lib/sunspot/dsl/standard_query.rb +63 -35
- data/lib/sunspot/field.rb +76 -4
- data/lib/sunspot/field_factory.rb +60 -11
- data/lib/sunspot/indexer.rb +70 -18
- data/lib/sunspot/query.rb +5 -4
- data/lib/sunspot/query/abstract_field_facet.rb +0 -2
- data/lib/sunspot/query/abstract_fulltext.rb +76 -0
- data/lib/sunspot/query/abstract_json_field_facet.rb +70 -0
- data/lib/sunspot/query/bbox.rb +5 -1
- data/lib/sunspot/query/common_query.rb +31 -6
- data/lib/sunspot/query/composite_fulltext.rb +58 -8
- data/lib/sunspot/query/date_field_json_facet.rb +25 -0
- data/lib/sunspot/query/dismax.rb +25 -71
- data/lib/sunspot/query/field_json_facet.rb +19 -0
- data/lib/sunspot/query/field_list.rb +15 -0
- data/lib/sunspot/query/field_stats.rb +61 -0
- data/lib/sunspot/query/function_query.rb +1 -2
- data/lib/sunspot/query/geo.rb +1 -1
- data/lib/sunspot/query/geofilt.rb +8 -3
- data/lib/sunspot/query/group.rb +46 -0
- data/lib/sunspot/query/group_query.rb +17 -0
- data/lib/sunspot/query/join.rb +88 -0
- data/lib/sunspot/query/more_like_this.rb +1 -1
- data/lib/sunspot/query/pagination.rb +12 -4
- data/lib/sunspot/query/range_json_facet.rb +28 -0
- data/lib/sunspot/query/restriction.rb +99 -13
- data/lib/sunspot/query/sort.rb +41 -0
- data/lib/sunspot/query/sort_composite.rb +7 -0
- data/lib/sunspot/query/spellcheck.rb +19 -0
- data/lib/sunspot/query/standard_query.rb +24 -2
- data/lib/sunspot/query/text_field_boost.rb +1 -3
- data/lib/sunspot/schema.rb +12 -3
- data/lib/sunspot/search.rb +4 -2
- data/lib/sunspot/search/abstract_search.rb +93 -43
- data/lib/sunspot/search/cursor_paginated_collection.rb +32 -0
- data/lib/sunspot/search/field_facet.rb +4 -4
- data/lib/sunspot/search/field_json_facet.rb +33 -0
- data/lib/sunspot/search/field_stats.rb +21 -0
- data/lib/sunspot/search/hit.rb +6 -1
- data/lib/sunspot/search/hit_enumerable.rb +4 -1
- data/lib/sunspot/search/json_facet_row.rb +40 -0
- data/lib/sunspot/search/json_facet_stats.rb +23 -0
- data/lib/sunspot/search/paginated_collection.rb +1 -0
- data/lib/sunspot/search/query_group.rb +74 -0
- data/lib/sunspot/search/standard_search.rb +70 -3
- data/lib/sunspot/search/stats_facet.rb +25 -0
- data/lib/sunspot/search/stats_json_row.rb +82 -0
- data/lib/sunspot/search/stats_row.rb +68 -0
- data/lib/sunspot/session.rb +62 -37
- data/lib/sunspot/session_proxy/class_sharding_session_proxy.rb +6 -4
- data/lib/sunspot/session_proxy/id_sharding_session_proxy.rb +16 -8
- data/lib/sunspot/session_proxy/master_slave_session_proxy.rb +2 -2
- data/lib/sunspot/session_proxy/retry_5xx_session_proxy.rb +1 -1
- data/lib/sunspot/session_proxy/sharding_session_proxy.rb +4 -2
- data/lib/sunspot/session_proxy/silent_fail_session_proxy.rb +1 -1
- data/lib/sunspot/session_proxy/thread_local_session_proxy.rb +6 -4
- data/lib/sunspot/setup.rb +42 -0
- data/lib/sunspot/type.rb +20 -0
- data/lib/sunspot/util.rb +78 -14
- data/lib/sunspot/version.rb +1 -1
- data/spec/api/adapters_spec.rb +40 -15
- data/spec/api/batcher_spec.rb +15 -15
- data/spec/api/binding_spec.rb +3 -3
- data/spec/api/class_set_spec.rb +6 -6
- data/spec/api/data_extractor_spec.rb +39 -0
- data/spec/api/hit_enumerable_spec.rb +32 -9
- data/spec/api/indexer/attributes_spec.rb +35 -30
- data/spec/api/indexer/batch_spec.rb +8 -7
- data/spec/api/indexer/dynamic_fields_spec.rb +8 -8
- data/spec/api/indexer/fixed_fields_spec.rb +16 -11
- data/spec/api/indexer/fulltext_spec.rb +8 -8
- data/spec/api/indexer/removal_spec.rb +24 -14
- data/spec/api/indexer_spec.rb +2 -2
- data/spec/api/query/advanced_manipulation_examples.rb +3 -3
- data/spec/api/query/connectives_examples.rb +26 -14
- data/spec/api/query/dsl_spec.rb +24 -6
- data/spec/api/query/dynamic_fields_examples.rb +18 -18
- data/spec/api/query/faceting_examples.rb +80 -61
- data/spec/api/query/fulltext_examples.rb +194 -40
- data/spec/api/query/function_spec.rb +116 -13
- data/spec/api/query/geo_examples.rb +8 -12
- data/spec/api/query/group_spec.rb +27 -5
- data/spec/api/query/highlighting_examples.rb +26 -26
- data/spec/api/query/join_spec.rb +19 -0
- data/spec/api/query/more_like_this_spec.rb +40 -27
- data/spec/api/query/ordering_pagination_examples.rb +37 -23
- data/spec/api/query/scope_examples.rb +39 -39
- data/spec/api/query/spatial_examples.rb +3 -3
- data/spec/api/query/spellcheck_examples.rb +20 -0
- data/spec/api/query/standard_spec.rb +3 -1
- data/spec/api/query/stats_examples.rb +66 -0
- data/spec/api/query/text_field_scoping_examples.rb +5 -5
- data/spec/api/query/types_spec.rb +4 -4
- data/spec/api/search/cursor_paginated_collection_spec.rb +35 -0
- data/spec/api/search/dynamic_fields_spec.rb +4 -4
- data/spec/api/search/faceting_spec.rb +55 -52
- data/spec/api/search/highlighting_spec.rb +7 -7
- data/spec/api/search/hits_spec.rb +43 -29
- data/spec/api/search/paginated_collection_spec.rb +19 -18
- data/spec/api/search/results_spec.rb +13 -13
- data/spec/api/search/search_spec.rb +3 -3
- data/spec/api/search/stats_spec.rb +94 -0
- data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +23 -16
- data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +16 -4
- data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +10 -6
- data/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb +11 -11
- data/spec/api/session_proxy/sharding_session_proxy_spec.rb +15 -14
- data/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +3 -3
- data/spec/api/session_proxy/spec_helper.rb +1 -1
- data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +40 -26
- data/spec/api/session_spec.rb +78 -38
- data/spec/api/sunspot_spec.rb +7 -4
- data/spec/helpers/integration_helper.rb +11 -1
- data/spec/helpers/query_helper.rb +1 -1
- data/spec/helpers/search_helper.rb +30 -0
- data/spec/integration/atomic_updates_spec.rb +58 -0
- data/spec/integration/dynamic_fields_spec.rb +31 -20
- data/spec/integration/faceting_spec.rb +252 -39
- data/spec/integration/field_grouping_spec.rb +47 -15
- data/spec/integration/field_lists_spec.rb +57 -0
- data/spec/integration/geospatial_spec.rb +34 -8
- data/spec/integration/highlighting_spec.rb +8 -8
- data/spec/integration/indexing_spec.rb +7 -6
- data/spec/integration/join_spec.rb +45 -0
- data/spec/integration/keyword_search_spec.rb +68 -38
- data/spec/integration/local_search_spec.rb +4 -4
- data/spec/integration/more_like_this_spec.rb +7 -7
- data/spec/integration/scoped_search_spec.rb +193 -74
- data/spec/integration/spellcheck_spec.rb +119 -0
- data/spec/integration/stats_spec.rb +88 -0
- data/spec/integration/stored_fields_spec.rb +1 -1
- data/spec/integration/test_pagination.rb +4 -4
- data/spec/integration/unicode_spec.rb +1 -1
- data/spec/mocks/adapters.rb +36 -0
- data/spec/mocks/connection.rb +5 -3
- data/spec/mocks/photo.rb +32 -1
- data/spec/mocks/post.rb +18 -3
- data/spec/spec_helper.rb +13 -8
- data/sunspot.gemspec +6 -4
- data/tasks/rdoc.rake +22 -14
- metadata +101 -44
- data/lib/sunspot/dsl/field_group.rb +0 -57
- data/lib/sunspot/query/field_group.rb +0 -37
@@ -2,114 +2,133 @@ shared_examples_for "facetable query" do
|
|
2
2
|
describe 'on fields' do
|
3
3
|
it 'does not turn faceting on if no facet requested' do
|
4
4
|
search
|
5
|
-
connection.
|
5
|
+
expect(connection).not_to have_last_search_with('facet')
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'turns faceting on if facet is requested' do
|
9
9
|
search do
|
10
10
|
facet :category_ids
|
11
11
|
end
|
12
|
-
connection.
|
12
|
+
expect(connection).to have_last_search_with(:facet => 'true')
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'requests single field facet' do
|
16
16
|
search do
|
17
17
|
facet :category_ids
|
18
18
|
end
|
19
|
-
connection.
|
19
|
+
expect(connection).to have_last_search_with(:"facet.field" => %w(category_ids_im))
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'requests multiple field facets' do
|
23
23
|
search do
|
24
24
|
facet :category_ids, :blog_id
|
25
25
|
end
|
26
|
-
connection.
|
26
|
+
expect(connection).to have_last_search_with(:"facet.field" => %w(category_ids_im blog_id_i))
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'sets facet sort by count' do
|
30
30
|
search do
|
31
31
|
facet :category_ids, :sort => :count
|
32
32
|
end
|
33
|
-
connection.
|
33
|
+
expect(connection).to have_last_search_with(:"f.category_ids_im.facet.sort" => 'true')
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'sets facet sort by index' do
|
37
37
|
search do
|
38
38
|
facet :category_ids, :sort => :index
|
39
39
|
end
|
40
|
-
connection.
|
40
|
+
expect(connection).to have_last_search_with(:"f.category_ids_im.facet.sort" => 'false')
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'raises ArgumentError if bogus facet sort provided' do
|
44
|
-
|
44
|
+
expect do
|
45
45
|
search do
|
46
46
|
facet :category_ids, :sort => :sideways
|
47
47
|
end
|
48
|
-
end.
|
48
|
+
end.to raise_error(ArgumentError)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'sets the facet limit' do
|
52
52
|
search do
|
53
53
|
facet :category_ids, :limit => 10
|
54
54
|
end
|
55
|
-
connection.
|
55
|
+
expect(connection).to have_last_search_with(:"f.category_ids_im.facet.limit" => 10)
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'sets the facet offset' do
|
59
59
|
search do
|
60
60
|
facet :category_ids, :offset => 10
|
61
61
|
end
|
62
|
-
connection.
|
62
|
+
expect(connection).to have_last_search_with(:"f.category_ids_im.facet.offset" => 10)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'sets the facet minimum count' do
|
66
66
|
search do
|
67
67
|
facet :category_ids, :minimum_count => 5
|
68
68
|
end
|
69
|
-
connection.
|
69
|
+
expect(connection).to have_last_search_with(:"f.category_ids_im.facet.mincount" => 5)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'sets the facet minimum count to zero if zeros are allowed' do
|
73
73
|
search do
|
74
74
|
facet :category_ids, :zeros => true
|
75
75
|
end
|
76
|
-
connection.
|
76
|
+
expect(connection).to have_last_search_with(:"f.category_ids_im.facet.mincount" => 0)
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'sets the facet minimum count to one by default' do
|
80
80
|
search do
|
81
81
|
facet :category_ids
|
82
82
|
end
|
83
|
-
connection.
|
83
|
+
expect(connection).to have_last_search_with(:"f.category_ids_im.facet.mincount" => 1)
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'sets the facet prefix' do
|
87
87
|
search do
|
88
88
|
facet :title, :prefix => 'Test'
|
89
89
|
end
|
90
|
-
connection.
|
90
|
+
expect(connection).to have_last_search_with(:"f.title_ss.facet.prefix" => 'Test')
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'sends a query facet for :any extra' do
|
94
94
|
search do
|
95
95
|
facet :category_ids, :extra => :any
|
96
96
|
end
|
97
|
-
connection.
|
97
|
+
expect(connection).to have_last_search_with(:"facet.query" => "category_ids_im:[* TO *]")
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'sends a query facet for :none extra' do
|
101
101
|
search do
|
102
102
|
facet :category_ids, :extra => :none
|
103
103
|
end
|
104
|
-
connection.
|
104
|
+
expect(connection).to have_last_search_with(:"facet.query" => "-category_ids_im:[* TO *]")
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'raises an ArgumentError if bogus extra is passed' do
|
108
|
-
|
108
|
+
expect do
|
109
109
|
search do
|
110
110
|
facet :category_ids, :extra => :bogus
|
111
111
|
end
|
112
|
-
end.
|
112
|
+
end.to raise_error(ArgumentError)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'tags and excludes a geofilt in a field facet' do
|
116
|
+
search do
|
117
|
+
post_geo = with(:coordinates_new).in_radius(32, -68, 1)
|
118
|
+
facet(:coordinates_new, :exclude => post_geo) do
|
119
|
+
row(0..10) do
|
120
|
+
with(:coordinates_new).in_radius(32, -68, 10)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
if connection.searches.last.has_key?(:"mlt.fl")
|
125
|
+
filter_tag = get_filter_tag('_query_:"{!geofilt sfield=coordinates_new_ll pt=32,-68 d=1}"')
|
126
|
+
else
|
127
|
+
filter_tag = get_filter_tag('{!geofilt sfield=coordinates_new_ll pt=32,-68 d=1}')
|
128
|
+
end
|
129
|
+
expect(connection).to have_last_search_with(
|
130
|
+
:"facet.query" => "{!ex=#{filter_tag}}_query_:\"{!geofilt sfield=coordinates_new_ll pt=32,-68 d=10}\""
|
131
|
+
)
|
113
132
|
end
|
114
133
|
|
115
134
|
it 'tags and excludes a scope filter in a field facet' do
|
@@ -118,7 +137,7 @@ shared_examples_for "facetable query" do
|
|
118
137
|
facet(:blog_id, :exclude => blog_filter)
|
119
138
|
end
|
120
139
|
filter_tag = get_filter_tag('blog_id_i:1')
|
121
|
-
connection.
|
140
|
+
expect(connection).to have_last_search_with(
|
122
141
|
:"facet.field" => %W({!ex=#{filter_tag}}blog_id_i)
|
123
142
|
)
|
124
143
|
end
|
@@ -132,7 +151,7 @@ shared_examples_for "facetable query" do
|
|
132
151
|
facet(:blog_id, :exclude => blog_filter)
|
133
152
|
end
|
134
153
|
filter_tag = get_filter_tag('(blog_id_i:1 OR blog_id_i:2)')
|
135
|
-
connection.
|
154
|
+
expect(connection).to have_last_search_with(
|
136
155
|
:"facet.field" => %W({!ex=#{filter_tag}}blog_id_i)
|
137
156
|
)
|
138
157
|
end
|
@@ -146,7 +165,7 @@ shared_examples_for "facetable query" do
|
|
146
165
|
filter_tags = %w(blog_id_i:1 category_ids_im:2).map do |phrase|
|
147
166
|
get_filter_tag(phrase)
|
148
167
|
end.join(',')
|
149
|
-
connection.
|
168
|
+
expect(connection).to have_last_search_with(
|
150
169
|
:"facet.field" => %W({!ex=#{filter_tags}}blog_id_i)
|
151
170
|
)
|
152
171
|
end
|
@@ -155,39 +174,39 @@ shared_examples_for "facetable query" do
|
|
155
174
|
search do
|
156
175
|
with(:blog_id, 1)
|
157
176
|
end
|
158
|
-
connection.
|
177
|
+
expect(connection).to have_last_search_including(:fq, "blog_id_i:1")
|
159
178
|
end
|
160
179
|
|
161
180
|
it 'names a field facet' do
|
162
181
|
search do
|
163
182
|
facet(:blog_id, :name => :blog)
|
164
183
|
end
|
165
|
-
connection.
|
184
|
+
expect(connection).to have_last_search_including(:"facet.field", "{!key=blog}blog_id_i")
|
166
185
|
end
|
167
186
|
|
168
187
|
it 'uses the custom field facet name in facet option parameters' do
|
169
188
|
search do
|
170
189
|
facet(:blog_id, :name => :blog, :sort => :count)
|
171
190
|
end
|
172
|
-
connection.
|
191
|
+
expect(connection).to have_last_search_with(:"f.blog.facet.sort" => 'true')
|
173
192
|
end
|
174
193
|
|
175
194
|
it 'raises an ArgumentError if exclusion attempted on a restricted field facet' do
|
176
|
-
|
195
|
+
expect do
|
177
196
|
search do
|
178
197
|
blog_filter = with(:blog_id, 1)
|
179
198
|
facet(:blog_id, :only => 1, :exclude => blog_filter)
|
180
199
|
end
|
181
|
-
end.
|
200
|
+
end.to raise_error(ArgumentError)
|
182
201
|
end
|
183
202
|
|
184
203
|
it 'raises an ArgumentError if exclusion attempted on a facet with :extra' do
|
185
|
-
|
204
|
+
expect do
|
186
205
|
search do
|
187
206
|
blog_filter = with(:blog_id, 1)
|
188
207
|
facet(:blog_id, :extra => :all, :exclude => blog_filter)
|
189
208
|
end
|
190
|
-
end.
|
209
|
+
end.to raise_error(ArgumentError)
|
191
210
|
end
|
192
211
|
end
|
193
212
|
|
@@ -201,21 +220,21 @@ shared_examples_for "facetable query" do
|
|
201
220
|
search do |query|
|
202
221
|
query.facet :published_at
|
203
222
|
end
|
204
|
-
connection.
|
223
|
+
expect(connection).not_to have_last_search_with(:"facet.date")
|
205
224
|
end
|
206
225
|
|
207
226
|
it 'sets the facet to a date facet if time range is specified' do
|
208
227
|
search do |query|
|
209
228
|
query.facet :published_at, :time_range => @time_range
|
210
229
|
end
|
211
|
-
connection.
|
230
|
+
expect(connection).to have_last_search_with(:"facet.date" => ['published_at_dt'])
|
212
231
|
end
|
213
232
|
|
214
233
|
it 'sets the facet start and end' do
|
215
234
|
search do |query|
|
216
235
|
query.facet :published_at, :time_range => @time_range
|
217
236
|
end
|
218
|
-
connection.
|
237
|
+
expect(connection).to have_last_search_with(
|
219
238
|
:"f.published_at_dt.facet.date.start" => '2009-06-01T04:00:00Z',
|
220
239
|
:"f.published_at_dt.facet.date.end" => '2009-07-01T04:00:00Z'
|
221
240
|
)
|
@@ -225,22 +244,22 @@ shared_examples_for "facetable query" do
|
|
225
244
|
search do |query|
|
226
245
|
query.facet :published_at, :time_range => @time_range
|
227
246
|
end
|
228
|
-
connection.
|
247
|
+
expect(connection).to have_last_search_with(:"f.published_at_dt.facet.date.gap" => "+86400SECONDS")
|
229
248
|
end
|
230
249
|
|
231
250
|
it 'uses custom time interval' do
|
232
251
|
search do |query|
|
233
252
|
query.facet :published_at, :time_range => @time_range, :time_interval => 3600
|
234
253
|
end
|
235
|
-
connection.
|
254
|
+
expect(connection).to have_last_search_with(:"f.published_at_dt.facet.date.gap" => "+3600SECONDS")
|
236
255
|
end
|
237
256
|
|
238
257
|
it 'does not allow date faceting on a non-date field' do
|
239
|
-
|
258
|
+
expect do
|
240
259
|
search do |query|
|
241
260
|
query.facet :blog_id, :time_range => @time_range
|
242
261
|
end
|
243
|
-
end.
|
262
|
+
end.to raise_error(ArgumentError)
|
244
263
|
end
|
245
264
|
end
|
246
265
|
|
@@ -253,21 +272,21 @@ shared_examples_for "facetable query" do
|
|
253
272
|
search do |query|
|
254
273
|
query.facet :average_rating
|
255
274
|
end
|
256
|
-
connection.
|
275
|
+
expect(connection).not_to have_last_search_with(:"facet.range")
|
257
276
|
end
|
258
277
|
|
259
278
|
it 'sets the facet to a range facet if the range is specified' do
|
260
279
|
search do |query|
|
261
280
|
query.facet :average_rating, :range => @range
|
262
281
|
end
|
263
|
-
connection.
|
282
|
+
expect(connection).to have_last_search_with(:"facet.range" => ['average_rating_ft'])
|
264
283
|
end
|
265
284
|
|
266
285
|
it 'sets the facet start and end' do
|
267
286
|
search do |query|
|
268
287
|
query.facet :average_rating, :range => @range
|
269
288
|
end
|
270
|
-
connection.
|
289
|
+
expect(connection).to have_last_search_with(
|
271
290
|
:"f.average_rating_ft.facet.range.start" => '2.0',
|
272
291
|
:"f.average_rating_ft.facet.range.end" => '4.0'
|
273
292
|
)
|
@@ -277,14 +296,14 @@ shared_examples_for "facetable query" do
|
|
277
296
|
search do |query|
|
278
297
|
query.facet :average_rating, :range => @range
|
279
298
|
end
|
280
|
-
connection.
|
299
|
+
expect(connection).to have_last_search_with(:"f.average_rating_ft.facet.range.gap" => "10")
|
281
300
|
end
|
282
301
|
|
283
302
|
it 'uses custom range interval' do
|
284
303
|
search do |query|
|
285
304
|
query.facet :average_rating, :range => @range, :range_interval => 1
|
286
305
|
end
|
287
|
-
connection.
|
306
|
+
expect(connection).to have_last_search_with(:"f.average_rating_ft.facet.range.gap" => "1")
|
288
307
|
end
|
289
308
|
|
290
309
|
it 'tags and excludes a scope filter in a range facet' do
|
@@ -293,7 +312,7 @@ shared_examples_for "facetable query" do
|
|
293
312
|
query.facet(:average_rating, :range => @range, :exclude => blog_filter)
|
294
313
|
end
|
295
314
|
filter_tag = get_filter_tag('blog_id_i:1')
|
296
|
-
connection.
|
315
|
+
expect(connection).to have_last_search_with(
|
297
316
|
:"facet.range" => %W({!ex=#{filter_tag}}average_rating_ft)
|
298
317
|
)
|
299
318
|
end
|
@@ -302,15 +321,15 @@ shared_examples_for "facetable query" do
|
|
302
321
|
search do |query|
|
303
322
|
query.facet :average_rating, :range => @range, :include => :edge
|
304
323
|
end
|
305
|
-
connection.
|
324
|
+
expect(connection).to have_last_search_with(:"f.average_rating_ft.facet.range.include" => "edge")
|
306
325
|
end
|
307
326
|
|
308
327
|
it 'does not allow date faceting on a non-continuous field' do
|
309
|
-
|
328
|
+
expect do
|
310
329
|
search do |query|
|
311
330
|
query.facet :title, :range => @range
|
312
331
|
end
|
313
|
-
end.
|
332
|
+
end.to raise_error(ArgumentError)
|
314
333
|
end
|
315
334
|
end
|
316
335
|
|
@@ -323,7 +342,7 @@ shared_examples_for "facetable query" do
|
|
323
342
|
end
|
324
343
|
end
|
325
344
|
end
|
326
|
-
connection.
|
345
|
+
expect(connection).to have_last_search_with(:facet => 'true')
|
327
346
|
end
|
328
347
|
|
329
348
|
it 'facets by query' do
|
@@ -334,7 +353,7 @@ shared_examples_for "facetable query" do
|
|
334
353
|
end
|
335
354
|
end
|
336
355
|
end
|
337
|
-
connection.
|
356
|
+
expect(connection).to have_last_search_with(:"facet.query" => 'average_rating_ft:[4\.0 TO 5\.0]')
|
338
357
|
end
|
339
358
|
|
340
359
|
it 'requests multiple query facets' do
|
@@ -348,7 +367,7 @@ shared_examples_for "facetable query" do
|
|
348
367
|
end
|
349
368
|
end
|
350
369
|
end
|
351
|
-
connection.
|
370
|
+
expect(connection).to have_last_search_with(
|
352
371
|
:"facet.query" => [
|
353
372
|
'average_rating_ft:[3\.0 TO 4\.0]',
|
354
373
|
'average_rating_ft:[4\.0 TO 5\.0]'
|
@@ -365,7 +384,7 @@ shared_examples_for "facetable query" do
|
|
365
384
|
end
|
366
385
|
end
|
367
386
|
end
|
368
|
-
connection.
|
387
|
+
expect(connection).to have_last_search_with(
|
369
388
|
:"facet.query" => '(category_ids_im:1 AND blog_id_i:2)'
|
370
389
|
)
|
371
390
|
end
|
@@ -381,7 +400,7 @@ shared_examples_for "facetable query" do
|
|
381
400
|
end
|
382
401
|
end
|
383
402
|
end
|
384
|
-
connection.
|
403
|
+
expect(connection).to have_last_search_with(
|
385
404
|
:"facet.query" => '(category_ids_im:1 OR blog_id_i:2)'
|
386
405
|
)
|
387
406
|
end
|
@@ -390,7 +409,7 @@ shared_examples_for "facetable query" do
|
|
390
409
|
search do
|
391
410
|
facet :category_ids, :only => [1, 3]
|
392
411
|
end
|
393
|
-
connection.
|
412
|
+
expect(connection).to have_last_search_with(
|
394
413
|
:"facet.query" => ['category_ids_im:1', 'category_ids_im:3']
|
395
414
|
)
|
396
415
|
end
|
@@ -399,7 +418,7 @@ shared_examples_for "facetable query" do
|
|
399
418
|
search do
|
400
419
|
facet :published_at, :only => [Time.utc(2009, 8, 28, 15, 33), Time.utc(2008,8, 28, 15, 33)]
|
401
420
|
end
|
402
|
-
connection.
|
421
|
+
expect(connection).to have_last_search_with(
|
403
422
|
:"facet.query" => [
|
404
423
|
'published_at_dt:2009\-08\-28T15\:33\:00Z',
|
405
424
|
'published_at_dt:2008\-08\-28T15\:33\:00Z'
|
@@ -411,7 +430,7 @@ shared_examples_for "facetable query" do
|
|
411
430
|
search do
|
412
431
|
facet(:foo) {}
|
413
432
|
end
|
414
|
-
connection.
|
433
|
+
expect(connection).not_to have_last_search_with(:"facet.query")
|
415
434
|
end
|
416
435
|
|
417
436
|
it 'ignores facet query row with no restrictions' do
|
@@ -423,7 +442,7 @@ shared_examples_for "facetable query" do
|
|
423
442
|
row(:baz) {}
|
424
443
|
end
|
425
444
|
end
|
426
|
-
connection.searches.last[:"facet.query"].
|
445
|
+
expect(connection.searches.last[:"facet.query"]).to be_a(String)
|
427
446
|
end
|
428
447
|
|
429
448
|
it 'tags and excludes a scope filter in a query facet' do
|
@@ -436,7 +455,7 @@ shared_examples_for "facetable query" do
|
|
436
455
|
end
|
437
456
|
end
|
438
457
|
filter_tag = get_filter_tag('blog_id_i:1')
|
439
|
-
connection.
|
458
|
+
expect(connection).to have_last_search_with(
|
440
459
|
:"facet.query" => "{!ex=#{filter_tag}}category_ids_im:1"
|
441
460
|
)
|
442
461
|
end
|
@@ -454,7 +473,7 @@ shared_examples_for "facetable query" do
|
|
454
473
|
end
|
455
474
|
end
|
456
475
|
filter_tag = get_filter_tag('(blog_id_i:1 OR blog_id_i:2)')
|
457
|
-
connection.
|
476
|
+
expect(connection).to have_last_search_with(
|
458
477
|
:"facet.query" => "{!ex=#{filter_tag}}category_ids_im:1"
|
459
478
|
)
|
460
479
|
end
|
@@ -472,7 +491,7 @@ shared_examples_for "facetable query" do
|
|
472
491
|
filter_tags = %w(blog_id_i:1 category_ids_im:2).map do |phrase|
|
473
492
|
get_filter_tag(phrase)
|
474
493
|
end.join(',')
|
475
|
-
connection.
|
494
|
+
expect(connection).to have_last_search_with(
|
476
495
|
:"facet.query" => "{!ex=#{filter_tags}}category_ids_im:1"
|
477
496
|
)
|
478
497
|
end
|
@@ -484,25 +503,25 @@ shared_examples_for "facetable query" do
|
|
484
503
|
row(:bar) {}
|
485
504
|
end
|
486
505
|
end
|
487
|
-
connection.
|
506
|
+
expect(connection).not_to have_last_search_with(:"facet.query")
|
488
507
|
end
|
489
508
|
|
490
509
|
it 'does not allow 0 arguments to facet method with block' do
|
491
|
-
|
510
|
+
expect do
|
492
511
|
search do
|
493
512
|
facet do
|
494
513
|
end
|
495
514
|
end
|
496
|
-
end.
|
515
|
+
end.to raise_error(ArgumentError)
|
497
516
|
end
|
498
517
|
|
499
518
|
it 'does not allow more than 1 argument to facet method with block' do
|
500
|
-
|
519
|
+
expect do
|
501
520
|
search do
|
502
521
|
facet :foo, :bar do
|
503
522
|
end
|
504
523
|
end
|
505
|
-
end.
|
524
|
+
end.to raise_error(ArgumentError)
|
506
525
|
end
|
507
526
|
end
|
508
527
|
end
|