sunspot 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -0
- data/TODO +6 -5
- data/bin/sunspot-solr +4 -0
- data/installer/config/schema.yml +24 -0
- data/lib/sunspot/composite_setup.rb +14 -0
- data/lib/sunspot/dsl/adjustable.rb +47 -0
- data/lib/sunspot/dsl/fulltext.rb +23 -8
- data/lib/sunspot/dsl/function.rb +14 -0
- data/lib/sunspot/dsl/functional.rb +41 -0
- data/lib/sunspot/dsl/more_like_this_query.rb +56 -0
- data/lib/sunspot/dsl/paginatable.rb +28 -0
- data/lib/sunspot/dsl/search.rb +1 -1
- data/lib/sunspot/dsl/{query.rb → standard_query.rb} +4 -49
- data/lib/sunspot/dsl.rb +3 -2
- data/lib/sunspot/field.rb +16 -2
- data/lib/sunspot/indexer.rb +1 -1
- data/lib/sunspot/installer/schema_builder.rb +1 -1
- data/lib/sunspot/installer/solrconfig_updater.rb +13 -0
- data/lib/sunspot/installer/task_helper.rb +1 -1
- data/lib/sunspot/query/abstract_field_facet.rb +5 -0
- data/lib/sunspot/query/boost_query.rb +5 -1
- data/lib/sunspot/query/{query.rb → common_query.rb} +26 -20
- data/lib/sunspot/query/composite_fulltext.rb +31 -0
- data/lib/sunspot/query/dismax.rb +45 -6
- data/lib/sunspot/query/function_query.rb +52 -0
- data/lib/sunspot/query/more_like_this.rb +60 -0
- data/lib/sunspot/query/more_like_this_query.rb +12 -0
- data/lib/sunspot/query/standard_query.rb +20 -0
- data/lib/sunspot/query/text_field_boost.rb +2 -0
- data/lib/sunspot/query.rb +3 -2
- data/lib/sunspot/search/abstract_search.rb +302 -0
- data/lib/sunspot/search/date_facet.rb +1 -1
- data/lib/sunspot/search/facet_row.rb +1 -1
- data/lib/sunspot/search/field_facet.rb +1 -1
- data/lib/sunspot/search/highlight.rb +1 -1
- data/lib/sunspot/search/hit.rb +1 -1
- data/lib/sunspot/search/more_like_this_search.rb +31 -0
- data/lib/sunspot/search/query_facet.rb +1 -1
- data/lib/sunspot/search/standard_search.rb +21 -0
- data/lib/sunspot/search.rb +3 -288
- data/lib/sunspot/server.rb +8 -4
- data/lib/sunspot/session.rb +30 -2
- data/lib/sunspot/session_proxy/master_slave_session_proxy.rb +1 -1
- data/lib/sunspot/session_proxy/sharding_session_proxy.rb +9 -0
- data/lib/sunspot/session_proxy/thread_local_session_proxy.rb +9 -2
- data/lib/sunspot/setup.rb +32 -3
- data/lib/sunspot/type.rb +74 -0
- data/lib/sunspot/util.rb +3 -2
- data/lib/sunspot/version.rb +1 -1
- data/lib/sunspot.rb +9 -1
- data/solr/solr/conf/schema.xml +12 -0
- data/solr/solr/conf/solrconfig.xml +6 -0
- data/spec/api/indexer/attributes_spec.rb +9 -3
- data/spec/api/indexer/fulltext_spec.rb +2 -2
- data/spec/api/indexer/removal_spec.rb +1 -1
- data/spec/api/query/advanced_manipulation_examples.rb +35 -0
- data/spec/api/query/{connectives_spec.rb → connectives_examples.rb} +19 -19
- data/spec/api/query/{dynamic_fields_spec.rb → dynamic_fields_examples.rb} +33 -17
- data/spec/api/query/{faceting_spec.rb → faceting_examples.rb} +146 -43
- data/spec/api/query/{fulltext_spec.rb → fulltext_examples.rb} +81 -47
- data/spec/api/query/function_spec.rb +70 -0
- data/spec/api/query/{highlighting_spec.rb → highlighting_examples.rb} +27 -27
- data/spec/api/query/{local_spec.rb → local_examples.rb} +5 -5
- data/spec/api/query/more_like_this_spec.rb +140 -0
- data/spec/api/query/{ordering_pagination_spec.rb → ordering_pagination_examples.rb} +16 -16
- data/spec/api/query/{scope_spec.rb → scope_examples.rb} +44 -61
- data/spec/api/query/standard_spec.rb +28 -0
- data/spec/api/query/{text_field_scoping_spec.rb → text_field_scoping_examples.rb} +5 -5
- data/spec/api/search/dynamic_fields_spec.rb +6 -0
- data/spec/api/search/faceting_spec.rb +10 -10
- data/spec/api/search/hits_spec.rb +1 -1
- data/spec/api/search/results_spec.rb +10 -0
- data/spec/api/server_spec.rb +6 -0
- data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +2 -2
- data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +17 -0
- data/spec/api/spec_helper.rb +2 -0
- data/spec/helpers/query_helper.rb +25 -0
- data/spec/helpers/search_helper.rb +4 -0
- data/spec/integration/faceting_spec.rb +8 -0
- data/spec/integration/keyword_search_spec.rb +75 -3
- data/spec/integration/local_search_spec.rb +1 -1
- data/spec/integration/more_like_this_spec.rb +43 -0
- data/spec/mocks/comment.rb +1 -1
- data/spec/mocks/connection.rb +27 -12
- data/spec/mocks/post.rb +5 -4
- data/spec/spec_helper.rb +4 -21
- data/tasks/gemspec.rake +1 -1
- metadata +39 -27
- data/spec/api/query/adjust_params_spec.rb +0 -37
- data/spec/api/query/facet_local_params_spec.rb +0 -103
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 1.0.5
|
9
|
+
version: 1.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Mat Brown
|
@@ -20,11 +20,14 @@ authors:
|
|
20
20
|
- Tom Coleman
|
21
21
|
- Matt Mitchell
|
22
22
|
- Nathan Beyer
|
23
|
+
- Kieran Topping
|
24
|
+
- Nicolas Braem
|
25
|
+
- Jeremy Ashkenas
|
23
26
|
autorequire:
|
24
27
|
bindir: bin
|
25
28
|
cert_chain: []
|
26
29
|
|
27
|
-
date: 2010-
|
30
|
+
date: 2010-04-01 00:00:00 -04:00
|
28
31
|
default_executable:
|
29
32
|
dependencies:
|
30
33
|
- !ruby/object:Gem::Dependency
|
@@ -92,7 +95,10 @@ files:
|
|
92
95
|
- lib/sunspot/session.rb
|
93
96
|
- lib/sunspot/type.rb
|
94
97
|
- lib/sunspot/version.rb
|
98
|
+
- lib/sunspot/search/standard_search.rb
|
99
|
+
- lib/sunspot/search/abstract_search.rb
|
95
100
|
- lib/sunspot/search/facet_row.rb
|
101
|
+
- lib/sunspot/search/more_like_this_search.rb
|
96
102
|
- lib/sunspot/search/hit.rb
|
97
103
|
- lib/sunspot/search/highlight.rb
|
98
104
|
- lib/sunspot/search/query_facet.rb
|
@@ -104,19 +110,24 @@ files:
|
|
104
110
|
- lib/sunspot/query/sort.rb
|
105
111
|
- lib/sunspot/query/connective.rb
|
106
112
|
- lib/sunspot/query/highlighting.rb
|
113
|
+
- lib/sunspot/query/composite_fulltext.rb
|
107
114
|
- lib/sunspot/query/scope.rb
|
108
115
|
- lib/sunspot/query/restriction.rb
|
109
116
|
- lib/sunspot/query/sort_composite.rb
|
117
|
+
- lib/sunspot/query/more_like_this.rb
|
110
118
|
- lib/sunspot/query/filter.rb
|
119
|
+
- lib/sunspot/query/standard_query.rb
|
111
120
|
- lib/sunspot/query/pagination.rb
|
121
|
+
- lib/sunspot/query/function_query.rb
|
112
122
|
- lib/sunspot/query/abstract_field_facet.rb
|
113
123
|
- lib/sunspot/query/boost_query.rb
|
114
124
|
- lib/sunspot/query/query_facet.rb
|
115
125
|
- lib/sunspot/query/date_field_facet.rb
|
116
126
|
- lib/sunspot/query/text_field_boost.rb
|
117
127
|
- lib/sunspot/query/local.rb
|
118
|
-
- lib/sunspot/query/
|
128
|
+
- lib/sunspot/query/more_like_this_query.rb
|
119
129
|
- lib/sunspot/query/field_facet.rb
|
130
|
+
- lib/sunspot/query/common_query.rb
|
120
131
|
- lib/sunspot/session_proxy/thread_local_session_proxy.rb
|
121
132
|
- lib/sunspot/session_proxy/class_sharding_session_proxy.rb
|
122
133
|
- lib/sunspot/session_proxy/master_slave_session_proxy.rb
|
@@ -142,11 +153,16 @@ files:
|
|
142
153
|
- lib/sunspot/util.rb
|
143
154
|
- lib/sunspot/dsl/fulltext.rb
|
144
155
|
- lib/sunspot/dsl/fields.rb
|
156
|
+
- lib/sunspot/dsl/adjustable.rb
|
145
157
|
- lib/sunspot/dsl/scope.rb
|
146
158
|
- lib/sunspot/dsl/restriction.rb
|
147
159
|
- lib/sunspot/dsl/search.rb
|
160
|
+
- lib/sunspot/dsl/standard_query.rb
|
161
|
+
- lib/sunspot/dsl/paginatable.rb
|
162
|
+
- lib/sunspot/dsl/function.rb
|
148
163
|
- lib/sunspot/dsl/query_facet.rb
|
149
|
-
- lib/sunspot/dsl/
|
164
|
+
- lib/sunspot/dsl/functional.rb
|
165
|
+
- lib/sunspot/dsl/more_like_this_query.rb
|
150
166
|
- lib/sunspot/dsl/field_query.rb
|
151
167
|
- lib/sunspot/field_factory.rb
|
152
168
|
- lib/sunspot/session_proxy.rb
|
@@ -161,6 +177,7 @@ files:
|
|
161
177
|
- spec/integration/local_search_spec.rb
|
162
178
|
- spec/integration/faceting_spec.rb
|
163
179
|
- spec/integration/scoped_search_spec.rb
|
180
|
+
- spec/integration/more_like_this_spec.rb
|
164
181
|
- spec/integration/highlighting_spec.rb
|
165
182
|
- spec/integration/keyword_search_spec.rb
|
166
183
|
- spec/integration/indexing_spec.rb
|
@@ -199,19 +216,21 @@ files:
|
|
199
216
|
- spec/api/adapters_spec.rb
|
200
217
|
- spec/api/server_spec.rb
|
201
218
|
- spec/api/query/dsl_spec.rb
|
219
|
+
- spec/api/query/faceting_examples.rb
|
202
220
|
- spec/api/query/spec_helper.rb
|
203
|
-
- spec/api/query/
|
204
|
-
- spec/api/query/
|
205
|
-
- spec/api/query/
|
206
|
-
- spec/api/query/
|
207
|
-
- spec/api/query/highlighting_spec.rb
|
208
|
-
- spec/api/query/ordering_pagination_spec.rb
|
209
|
-
- spec/api/query/dynamic_fields_spec.rb
|
221
|
+
- spec/api/query/highlighting_examples.rb
|
222
|
+
- spec/api/query/more_like_this_spec.rb
|
223
|
+
- spec/api/query/local_examples.rb
|
224
|
+
- spec/api/query/ordering_pagination_examples.rb
|
210
225
|
- spec/api/query/types_spec.rb
|
211
|
-
- spec/api/query/
|
212
|
-
- spec/api/query/
|
213
|
-
- spec/api/query/
|
214
|
-
- spec/api/query/
|
226
|
+
- spec/api/query/function_spec.rb
|
227
|
+
- spec/api/query/advanced_manipulation_examples.rb
|
228
|
+
- spec/api/query/fulltext_examples.rb
|
229
|
+
- spec/api/query/text_field_scoping_examples.rb
|
230
|
+
- spec/api/query/connectives_examples.rb
|
231
|
+
- spec/api/query/dynamic_fields_examples.rb
|
232
|
+
- spec/api/query/standard_spec.rb
|
233
|
+
- spec/api/query/scope_examples.rb
|
215
234
|
- spec/api/session_proxy/spec_helper.rb
|
216
235
|
- spec/api/session_proxy/master_slave_session_proxy_spec.rb
|
217
236
|
- spec/api/session_proxy/class_sharding_session_proxy_spec.rb
|
@@ -287,6 +306,7 @@ test_files:
|
|
287
306
|
- spec/integration/local_search_spec.rb
|
288
307
|
- spec/integration/faceting_spec.rb
|
289
308
|
- spec/integration/scoped_search_spec.rb
|
309
|
+
- spec/integration/more_like_this_spec.rb
|
290
310
|
- spec/integration/highlighting_spec.rb
|
291
311
|
- spec/integration/keyword_search_spec.rb
|
292
312
|
- spec/integration/indexing_spec.rb
|
@@ -309,18 +329,10 @@ test_files:
|
|
309
329
|
- spec/api/adapters_spec.rb
|
310
330
|
- spec/api/server_spec.rb
|
311
331
|
- spec/api/query/dsl_spec.rb
|
312
|
-
- spec/api/query/
|
313
|
-
- spec/api/query/connectives_spec.rb
|
314
|
-
- spec/api/query/adjust_params_spec.rb
|
315
|
-
- spec/api/query/local_spec.rb
|
316
|
-
- spec/api/query/highlighting_spec.rb
|
317
|
-
- spec/api/query/ordering_pagination_spec.rb
|
318
|
-
- spec/api/query/dynamic_fields_spec.rb
|
332
|
+
- spec/api/query/more_like_this_spec.rb
|
319
333
|
- spec/api/query/types_spec.rb
|
320
|
-
- spec/api/query/
|
321
|
-
- spec/api/query/
|
322
|
-
- spec/api/query/text_field_scoping_spec.rb
|
323
|
-
- spec/api/query/fulltext_spec.rb
|
334
|
+
- spec/api/query/function_spec.rb
|
335
|
+
- spec/api/query/standard_spec.rb
|
324
336
|
- spec/api/session_proxy/master_slave_session_proxy_spec.rb
|
325
337
|
- spec/api/session_proxy/class_sharding_session_proxy_spec.rb
|
326
338
|
- spec/api/session_proxy/id_sharding_session_proxy_spec.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
|
3
|
-
describe 'typed query' do
|
4
|
-
it "should send query to solr with adjusted parameters (keyword example)" do
|
5
|
-
session.search Post do
|
6
|
-
keywords 'keyword search'
|
7
|
-
adjust_solr_params do |params|
|
8
|
-
params[:q] = 'new search'
|
9
|
-
params[:some] = 'param'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
connection.should have_last_search_with(:q => 'new search')
|
13
|
-
connection.should have_last_search_with(:some => 'param')
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should work, even without another dsl command" do
|
17
|
-
session.search Post do
|
18
|
-
adjust_solr_params do |params|
|
19
|
-
params[:q] = 'napoleon dynamite'
|
20
|
-
params[:qt] = 'complicated'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
connection.should have_last_search_with(:q => 'napoleon dynamite')
|
24
|
-
connection.should have_last_search_with(:qt => 'complicated')
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should be able to extend parameters" do
|
28
|
-
session.search Post do
|
29
|
-
keywords 'keyword search'
|
30
|
-
adjust_solr_params do |params|
|
31
|
-
params[:q] += ' AND something_s:more'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
connection.should have_last_search_with(:q => 'keyword search AND something_s:more')
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
|
3
|
-
describe 'facet local params' do
|
4
|
-
it 'tags and excludes a scope filter in a field facet' do
|
5
|
-
session.search(Post) do
|
6
|
-
blog_filter = with(:blog_id, 1)
|
7
|
-
facet(:blog_id, :exclude => blog_filter)
|
8
|
-
end
|
9
|
-
filter_tag = get_filter_tag('blog_id_i:1')
|
10
|
-
connection.should have_last_search_with(
|
11
|
-
:"facet.field" => %W({!ex=#{filter_tag}}blog_id_i)
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'tags and excludes a disjunction filter in a field facet' do
|
16
|
-
session.search(Post) do
|
17
|
-
blog_filter = any_of do
|
18
|
-
with(:blog_id, 1)
|
19
|
-
with(:blog_id, 2)
|
20
|
-
end
|
21
|
-
facet(:blog_id, :exclude => blog_filter)
|
22
|
-
end
|
23
|
-
filter_tag = get_filter_tag('(blog_id_i:1 OR blog_id_i:2)')
|
24
|
-
connection.should have_last_search_with(
|
25
|
-
:"facet.field" => %W({!ex=#{filter_tag}}blog_id_i)
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'tags and excludes multiple filters in a field facet' do
|
30
|
-
session.search(Post) do
|
31
|
-
blog_filter = with(:blog_id, 1)
|
32
|
-
category_filter = with(:category_ids, 2)
|
33
|
-
facet(:blog_id, :exclude => [blog_filter, category_filter])
|
34
|
-
end
|
35
|
-
filter_tags = %w(blog_id_i:1 category_ids_im:2).map do |phrase|
|
36
|
-
get_filter_tag(phrase)
|
37
|
-
end.join(',')
|
38
|
-
connection.should have_last_search_with(
|
39
|
-
:"facet.field" => %W({!ex=#{filter_tags}}blog_id_i)
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'does not tag a filter if it is not excluded' do
|
44
|
-
session.search(Post) do
|
45
|
-
with(:blog_id, 1)
|
46
|
-
end
|
47
|
-
connection.should have_last_search_including(:fq, "blog_id_i:1")
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'names a field facet' do
|
51
|
-
session.search(Post) do
|
52
|
-
facet(:blog_id, :name => :blog)
|
53
|
-
end
|
54
|
-
connection.should have_last_search_including(:"facet.field", "{!key=blog}blog_id_i")
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'uses the custom field facet name in facet option parameters' do
|
58
|
-
session.search(Post) do
|
59
|
-
facet(:blog_id, :name => :blog, :sort => :count)
|
60
|
-
end
|
61
|
-
connection.should have_last_search_with(:"f.blog.facet.sort" => 'true')
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'raises an ArgumentError if exclusion attempted on a query facet' do
|
65
|
-
lambda do
|
66
|
-
session.search(Post) do
|
67
|
-
blog_filter = with(:blog_id, 1)
|
68
|
-
facet(:bad, :exclude => blog_filter) do
|
69
|
-
row(:bogus) { with(:blog_id, 1) }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end.should raise_error(ArgumentError)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'raises an ArgumentError if exclusion attempted on a restricted field facet' do
|
76
|
-
lambda do
|
77
|
-
session.search(Post) do
|
78
|
-
blog_filter = with(:blog_id, 1)
|
79
|
-
facet(:blog_id, :only => 1, :exclude => blog_filter)
|
80
|
-
end
|
81
|
-
end.should raise_error(ArgumentError)
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'raises an ArgumentError if exclusion attempted on a facet with :extra' do
|
85
|
-
lambda do
|
86
|
-
session.search(Post) do
|
87
|
-
blog_filter = with(:blog_id, 1)
|
88
|
-
facet(:blog_id, :extra => :all, :exclude => blog_filter)
|
89
|
-
end
|
90
|
-
end.should raise_error(ArgumentError)
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def get_filter_tag(boolean_query)
|
96
|
-
connection.searches.last[:fq].each do |fq|
|
97
|
-
if match = fq.match(/^\{!tag=(.+)\}#{Regexp.escape(boolean_query)}$/)
|
98
|
-
return match[1]
|
99
|
-
end
|
100
|
-
end
|
101
|
-
nil
|
102
|
-
end
|
103
|
-
end
|