greglu-solr-ruby 0.0.7
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/CHANGES.yml +50 -0
- data/LICENSE.txt +201 -0
- data/README +56 -0
- data/Rakefile +190 -0
- data/examples/delicious_library/dl_importer.rb +60 -0
- data/examples/delicious_library/sample_export.txt +164 -0
- data/examples/marc/marc_importer.rb +106 -0
- data/examples/tang/tang_importer.rb +58 -0
- data/lib/solr.rb +21 -0
- data/lib/solr/connection.rb +179 -0
- data/lib/solr/document.rb +73 -0
- data/lib/solr/exception.rb +13 -0
- data/lib/solr/field.rb +39 -0
- data/lib/solr/importer.rb +19 -0
- data/lib/solr/importer/array_mapper.rb +26 -0
- data/lib/solr/importer/delimited_file_source.rb +38 -0
- data/lib/solr/importer/hpricot_mapper.rb +27 -0
- data/lib/solr/importer/mapper.rb +51 -0
- data/lib/solr/importer/solr_source.rb +43 -0
- data/lib/solr/importer/xpath_mapper.rb +35 -0
- data/lib/solr/indexer.rb +52 -0
- data/lib/solr/request.rb +26 -0
- data/lib/solr/request/add_document.rb +63 -0
- data/lib/solr/request/base.rb +36 -0
- data/lib/solr/request/commit.rb +31 -0
- data/lib/solr/request/delete.rb +50 -0
- data/lib/solr/request/dismax.rb +46 -0
- data/lib/solr/request/index_info.rb +22 -0
- data/lib/solr/request/modify_document.rb +51 -0
- data/lib/solr/request/optimize.rb +21 -0
- data/lib/solr/request/ping.rb +36 -0
- data/lib/solr/request/select.rb +56 -0
- data/lib/solr/request/spellcheck.rb +30 -0
- data/lib/solr/request/standard.rb +374 -0
- data/lib/solr/request/update.rb +23 -0
- data/lib/solr/response.rb +27 -0
- data/lib/solr/response/add_document.rb +17 -0
- data/lib/solr/response/base.rb +42 -0
- data/lib/solr/response/commit.rb +17 -0
- data/lib/solr/response/delete.rb +13 -0
- data/lib/solr/response/dismax.rb +20 -0
- data/lib/solr/response/index_info.rb +26 -0
- data/lib/solr/response/modify_document.rb +17 -0
- data/lib/solr/response/optimize.rb +14 -0
- data/lib/solr/response/ping.rb +28 -0
- data/lib/solr/response/ruby.rb +42 -0
- data/lib/solr/response/select.rb +17 -0
- data/lib/solr/response/spellcheck.rb +20 -0
- data/lib/solr/response/standard.rb +60 -0
- data/lib/solr/response/xml.rb +42 -0
- data/lib/solr/solrtasks.rb +27 -0
- data/lib/solr/util.rb +32 -0
- data/lib/solr/xml.rb +47 -0
- data/script/setup.rb +14 -0
- data/script/solrshell +18 -0
- data/solr-ruby.gemspec +26 -0
- data/solr/conf/admin-extra.html +31 -0
- data/solr/conf/protwords.txt +21 -0
- data/solr/conf/schema.xml +221 -0
- data/solr/conf/scripts.conf +24 -0
- data/solr/conf/solrconfig.xml +394 -0
- data/solr/conf/stopwords.txt +58 -0
- data/solr/conf/synonyms.txt +31 -0
- data/solr/conf/xslt/example.xsl +132 -0
- data/test/conf/admin-extra.html +31 -0
- data/test/conf/protwords.txt +21 -0
- data/test/conf/schema.xml +237 -0
- data/test/conf/scripts.conf +24 -0
- data/test/conf/solrconfig.xml +376 -0
- data/test/conf/stopwords.txt +58 -0
- data/test/conf/synonyms.txt +31 -0
- data/test/functional/server_test.rb +218 -0
- data/test/functional/test_solr_server.rb +104 -0
- data/test/unit/add_document_test.rb +40 -0
- data/test/unit/array_mapper_test.rb +37 -0
- data/test/unit/changes_yaml_test.rb +21 -0
- data/test/unit/commit_test.rb +41 -0
- data/test/unit/connection_test.rb +55 -0
- data/test/unit/data_mapper_test.rb +75 -0
- data/test/unit/delete_test.rb +56 -0
- data/test/unit/delimited_file_source_test.rb +29 -0
- data/test/unit/dismax_request_test.rb +26 -0
- data/test/unit/document_test.rb +69 -0
- data/test/unit/field_test.rb +48 -0
- data/test/unit/hpricot_mapper_test.rb +44 -0
- data/test/unit/hpricot_test_file.xml +26 -0
- data/test/unit/indexer_test.rb +57 -0
- data/test/unit/modify_document_test.rb +24 -0
- data/test/unit/ping_test.rb +51 -0
- data/test/unit/request_test.rb +61 -0
- data/test/unit/response_test.rb +43 -0
- data/test/unit/select_test.rb +25 -0
- data/test/unit/solr_mock_base.rb +40 -0
- data/test/unit/spellcheck_response_test.rb +26 -0
- data/test/unit/spellchecker_request_test.rb +27 -0
- data/test/unit/standard_request_test.rb +324 -0
- data/test/unit/standard_response_test.rb +174 -0
- data/test/unit/suite.rb +16 -0
- data/test/unit/tab_delimited.txt +2 -0
- data/test/unit/util_test.rb +24 -0
- data/test/unit/xpath_mapper_test.rb +38 -0
- data/test/unit/xpath_test_file.xml +25 -0
- metadata +173 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
2
|
+
# (the "License"); you may not use this file except in compliance with
|
|
3
|
+
# the License. You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and
|
|
11
|
+
# limitations under the License.
|
|
12
|
+
|
|
13
|
+
class Solr::Request::Standard < Solr::Request::Select
|
|
14
|
+
|
|
15
|
+
VALID_PARAMS = [:query, :sort, :default_field, :operator, :start, :rows, :shards,
|
|
16
|
+
:filter_queries, :field_list, :debug_query, :explain_other, :facets, :highlighting, :mlt]
|
|
17
|
+
|
|
18
|
+
def initialize(params)
|
|
19
|
+
super('standard')
|
|
20
|
+
|
|
21
|
+
raise "Invalid parameters: #{(params.keys - VALID_PARAMS).join(',')}" unless
|
|
22
|
+
(params.keys - VALID_PARAMS).empty?
|
|
23
|
+
|
|
24
|
+
raise ":query parameter required" unless params[:query]
|
|
25
|
+
|
|
26
|
+
@params = params.dup
|
|
27
|
+
|
|
28
|
+
# Validate operator
|
|
29
|
+
if params[:operator]
|
|
30
|
+
raise "Only :and/:or operators allowed" unless
|
|
31
|
+
[:and, :or].include?(params[:operator])
|
|
32
|
+
|
|
33
|
+
@params[:operator] = params[:operator].to_s.upcase
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Validate start, rows can be transformed to ints
|
|
37
|
+
@params[:start] = params[:start].to_i if params[:start]
|
|
38
|
+
@params[:rows] = params[:rows].to_i if params[:rows]
|
|
39
|
+
|
|
40
|
+
@params[:field_list] ||= ["*","score"]
|
|
41
|
+
|
|
42
|
+
@params[:shards] ||= []
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def to_hash
|
|
46
|
+
hash = {}
|
|
47
|
+
|
|
48
|
+
# standard request param processing
|
|
49
|
+
hash[:sort] = @params[:sort].collect do |sort|
|
|
50
|
+
key = sort.keys[0]
|
|
51
|
+
"#{key.to_s} #{sort[key] == :descending ? 'desc' : 'asc'}"
|
|
52
|
+
end.join(',') if @params[:sort]
|
|
53
|
+
hash[:q] = @params[:query]
|
|
54
|
+
hash["q.op"] = @params[:operator]
|
|
55
|
+
hash[:df] = @params[:default_field]
|
|
56
|
+
|
|
57
|
+
# common parameter processing
|
|
58
|
+
hash[:start] = @params[:start]
|
|
59
|
+
hash[:rows] = @params[:rows]
|
|
60
|
+
hash[:fq] = @params[:filter_queries]
|
|
61
|
+
hash[:fl] = @params[:field_list].join(',')
|
|
62
|
+
hash[:debugQuery] = @params[:debug_query]
|
|
63
|
+
hash[:explainOther] = @params[:explain_other]
|
|
64
|
+
hash[:shards] = @params[:shards].join(',') unless @params[:shards].empty?
|
|
65
|
+
|
|
66
|
+
# facet parameter processing
|
|
67
|
+
if @params[:facets]
|
|
68
|
+
# TODO need validation of all that is under the :facets Hash too
|
|
69
|
+
hash[:facet] = true
|
|
70
|
+
hash["facet.field"] = []
|
|
71
|
+
hash["facet.query"] = @params[:facets][:queries]
|
|
72
|
+
hash["facet.sort"] = (@params[:facets][:sort] == :count) if @params[:facets][:sort]
|
|
73
|
+
hash["facet.limit"] = @params[:facets][:limit]
|
|
74
|
+
hash["facet.missing"] = @params[:facets][:missing]
|
|
75
|
+
hash["facet.mincount"] = @params[:facets][:mincount]
|
|
76
|
+
hash["facet.prefix"] = @params[:facets][:prefix]
|
|
77
|
+
hash["facet.offset"] = @params[:facets][:offset]
|
|
78
|
+
hash["facet.method"] = @params[:facets][:method] if @params[:facets][:method]
|
|
79
|
+
if @params[:facets][:fields] # facet fields are optional (could be facet.query only)
|
|
80
|
+
@params[:facets][:fields].each do |f|
|
|
81
|
+
if f.kind_of? Hash
|
|
82
|
+
key = f.keys[0]
|
|
83
|
+
value = f[key]
|
|
84
|
+
hash["facet.field"] << key
|
|
85
|
+
hash["f.#{key}.facet.sort"] = (value[:sort] == :count) if value[:sort]
|
|
86
|
+
hash["f.#{key}.facet.limit"] = value[:limit]
|
|
87
|
+
hash["f.#{key}.facet.missing"] = value[:missing]
|
|
88
|
+
hash["f.#{key}.facet.mincount"] = value[:mincount]
|
|
89
|
+
hash["f.#{key}.facet.prefix"] = value[:prefix]
|
|
90
|
+
hash["f.#{key}.facet.offset"] = value[:offset]
|
|
91
|
+
else
|
|
92
|
+
hash["facet.field"] << f
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# highlighting parameter processing - http://wiki.apache.org/solr/HighlightingParameters
|
|
99
|
+
if @params[:highlighting]
|
|
100
|
+
hash[:hl] = true
|
|
101
|
+
hash["hl.fl"] = @params[:highlighting][:field_list].join(',') if @params[:highlighting][:field_list]
|
|
102
|
+
|
|
103
|
+
snippets = @params[:highlighting][:max_snippets]
|
|
104
|
+
if snippets
|
|
105
|
+
if snippets.kind_of? Hash
|
|
106
|
+
if snippets[:default]
|
|
107
|
+
hash["hl.snippets"] = snippets[:default]
|
|
108
|
+
end
|
|
109
|
+
if snippets[:fields]
|
|
110
|
+
snippets[:fields].each do |k,v|
|
|
111
|
+
hash["f.#{k}.hl.snippets"] = v
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
else
|
|
115
|
+
hash["hl.snippets"] = snippets
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
fragsize = @params[:highlighting][:fragment_size]
|
|
120
|
+
if fragsize
|
|
121
|
+
if fragsize.kind_of? Hash
|
|
122
|
+
if fragsize[:default]
|
|
123
|
+
hash["hl.fragsize"] = fragsize[:default]
|
|
124
|
+
end
|
|
125
|
+
if fragsize[:fields]
|
|
126
|
+
fragsize[:fields].each do |k,v|
|
|
127
|
+
hash["f.#{k}.hl.fragsize"] = v
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
else
|
|
131
|
+
hash["hl.fragsize"] = fragsize
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
rfm = @params[:highlighting][:require_field_match]
|
|
136
|
+
if nil != rfm
|
|
137
|
+
if rfm.kind_of? Hash
|
|
138
|
+
if nil != rfm[:default]
|
|
139
|
+
hash["hl.requireFieldMatch"] = rfm[:default]
|
|
140
|
+
end
|
|
141
|
+
if rfm[:fields]
|
|
142
|
+
rfm[:fields].each do |k,v|
|
|
143
|
+
hash["f.#{k}.hl.requireFieldMatch"] = v
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
else
|
|
147
|
+
hash["hl.requireFieldMatch"] = rfm
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
mac = @params[:highlighting][:max_analyzed_chars]
|
|
152
|
+
if mac
|
|
153
|
+
if mac.kind_of? Hash
|
|
154
|
+
if mac[:default]
|
|
155
|
+
hash["hl.maxAnalyzedChars"] = mac[:default]
|
|
156
|
+
end
|
|
157
|
+
if mac[:fields]
|
|
158
|
+
mac[:fields].each do |k,v|
|
|
159
|
+
hash["f.#{k}.hl.maxAnalyzedChars"] = v
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
else
|
|
163
|
+
hash["hl.maxAnalyzedChars"] = mac
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
prefix = @params[:highlighting][:prefix]
|
|
168
|
+
if prefix
|
|
169
|
+
if prefix.kind_of? Hash
|
|
170
|
+
if prefix[:default]
|
|
171
|
+
hash["hl.simple.pre"] = prefix[:default]
|
|
172
|
+
end
|
|
173
|
+
if prefix[:fields]
|
|
174
|
+
prefix[:fields].each do |k,v|
|
|
175
|
+
hash["f.#{k}.hl.simple.pre"] = v
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
else
|
|
179
|
+
hash["hl.simple.pre"] = prefix
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
suffix = @params[:highlighting][:suffix]
|
|
184
|
+
if suffix
|
|
185
|
+
if suffix.kind_of? Hash
|
|
186
|
+
if suffix[:default]
|
|
187
|
+
hash["hl.simple.post"] = suffix[:default]
|
|
188
|
+
end
|
|
189
|
+
if suffix[:fields]
|
|
190
|
+
suffix[:fields].each do |k,v|
|
|
191
|
+
hash["f.#{k}.hl.simple.post"] = v
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
else
|
|
195
|
+
hash["hl.simple.post"] = suffix
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
formatter = @params[:highlighting][:formatter]
|
|
200
|
+
if formatter
|
|
201
|
+
if formatter.kind_of? Hash
|
|
202
|
+
if formatter[:default]
|
|
203
|
+
hash["hl.formatter"] = formatter[:default]
|
|
204
|
+
end
|
|
205
|
+
if formatter[:fields]
|
|
206
|
+
formatter[:fields].each do |k,v|
|
|
207
|
+
hash["f.#{k}.hl.formatter"] = v
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
else
|
|
211
|
+
hash["hl.formatter"] = formatter
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
fragmenter = @params[:highlighting][:fragmenter]
|
|
216
|
+
if fragmenter
|
|
217
|
+
if fragmenter.kind_of? Hash
|
|
218
|
+
if fragmenter[:default]
|
|
219
|
+
hash["hl.fragmenter"] = fragmenter[:default]
|
|
220
|
+
end
|
|
221
|
+
if fragmenter[:fields]
|
|
222
|
+
fragmenter[:fields].each do |k,v|
|
|
223
|
+
hash["f.#{k}.hl.fragmenter"] = v
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
else
|
|
227
|
+
hash["hl.fragmenter"] = fragmenter
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
merge_contiguous = @params[:highlighting][:merge_contiguous]
|
|
232
|
+
if nil != merge_contiguous
|
|
233
|
+
if merge_contiguous.kind_of? Hash
|
|
234
|
+
if nil != merge_contiguous[:default]
|
|
235
|
+
hash["hl.mergeContiguous"] = merge_contiguous[:default]
|
|
236
|
+
end
|
|
237
|
+
if merge_contiguous[:fields]
|
|
238
|
+
merge_contiguous[:fields].each do |k,v|
|
|
239
|
+
hash["f.#{k}.hl.mergeContiguous"] = v
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
else
|
|
243
|
+
hash["hl.mergeContiguous"] = merge_contiguous
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
increment = @params[:highlighting][:increment]
|
|
248
|
+
if increment
|
|
249
|
+
if increment.kind_of? Hash
|
|
250
|
+
if increment[:default]
|
|
251
|
+
hash["hl.increment"] = increment[:default]
|
|
252
|
+
end
|
|
253
|
+
if increment[:fields]
|
|
254
|
+
increment[:fields].each do |k,v|
|
|
255
|
+
hash["f.#{k}.hl.increment"] = v
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
else
|
|
259
|
+
hash["hl.increment"] = increment
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# support "old style"
|
|
264
|
+
alternate_fields = @params[:highlighting][:alternate_fields]
|
|
265
|
+
if alternate_fields
|
|
266
|
+
alternate_fields.each do |f,v|
|
|
267
|
+
hash["f.#{f}.hl.alternateField"] = v
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
alternate_field = @params[:highlighting][:alternate_field]
|
|
272
|
+
if alternate_field
|
|
273
|
+
if alternate_field.kind_of? Hash
|
|
274
|
+
if alternate_field[:default]
|
|
275
|
+
hash["hl.alternateField"] = alternate_field[:default]
|
|
276
|
+
end
|
|
277
|
+
if alternate_field[:fields]
|
|
278
|
+
alternate_field[:fields].each do |k,v|
|
|
279
|
+
hash["f.#{k}.hl.alternateField"] = v
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
else
|
|
283
|
+
hash["hl.alternateField"] = alternate_field
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
mafl = @params[:highlighting][:max_alternate_field_length]
|
|
288
|
+
if mafl
|
|
289
|
+
if mafl.kind_of? Hash
|
|
290
|
+
if mafl[:default]
|
|
291
|
+
hash["hl.maxAlternateFieldLength"] = mafl[:default]
|
|
292
|
+
end
|
|
293
|
+
if mafl[:fields]
|
|
294
|
+
mafl[:fields].each do |k,v|
|
|
295
|
+
hash["f.#{k}.hl.maxAlternateFieldLength"] = v
|
|
296
|
+
end
|
|
297
|
+
else
|
|
298
|
+
# support "old style"
|
|
299
|
+
mafl.each do |k,v|
|
|
300
|
+
hash["f.#{k}.hl.maxAlternateFieldLength"] = v
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
else
|
|
304
|
+
hash["hl.maxAlternateFieldLength"] = mafl
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
hash["hl.usePhraseHighlighter"] = @params[:highlighting][:use_phrase_highlighter]
|
|
309
|
+
|
|
310
|
+
regex = @params[:highlighting][:regex]
|
|
311
|
+
if regex
|
|
312
|
+
if regex[:slop]
|
|
313
|
+
if regex[:slop].kind_of? Hash
|
|
314
|
+
if regex[:slop][:default]
|
|
315
|
+
hash["hl.regex.slop"] = regex[:slop][:default]
|
|
316
|
+
end
|
|
317
|
+
if regex[:slop][:fields]
|
|
318
|
+
regex[:slop][:fields].each do |k,v|
|
|
319
|
+
hash["f.#{k}.hl.regex.slop"] = v
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
else
|
|
323
|
+
hash["hl.regex.slop"] = regex[:slop]
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
if regex[:pattern]
|
|
327
|
+
if regex[:pattern].kind_of? Hash
|
|
328
|
+
if regex[:pattern][:default]
|
|
329
|
+
hash["hl.regex.pattern"] = regex[:pattern][:default]
|
|
330
|
+
end
|
|
331
|
+
if regex[:pattern][:fields]
|
|
332
|
+
regex[:pattern][:fields].each do |k,v|
|
|
333
|
+
hash["f.#{k}.hl.regex.pattern"] = v
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
else
|
|
337
|
+
hash["hl.regex.pattern"] = regex[:pattern]
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
if regex[:max_analyzed_chars]
|
|
341
|
+
if regex[:max_analyzed_chars].kind_of? Hash
|
|
342
|
+
if regex[:max_analyzed_chars][:default]
|
|
343
|
+
hash["hl.regex.maxAnalyzedChars"] = regex[:max_analyzed_chars][:default]
|
|
344
|
+
end
|
|
345
|
+
if regex[:max_analyzed_chars][:fields]
|
|
346
|
+
regex[:max_analyzed_chars][:fields].each do |k,v|
|
|
347
|
+
hash["f.#{k}.hl.regex.maxAnalyzedChars"] = v
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
else
|
|
351
|
+
hash["hl.regex.maxAnalyzedChars"] = regex[:max_analyzed_chars]
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
if @params[:mlt]
|
|
359
|
+
hash[:mlt] = true
|
|
360
|
+
hash["mlt.count"] = @params[:mlt][:count]
|
|
361
|
+
hash["mlt.fl"] = @params[:mlt][:field_list].join(',')
|
|
362
|
+
hash["mlt.mintf"] = @params[:mlt][:min_term_freq]
|
|
363
|
+
hash["mlt.mindf"] = @params[:mlt][:min_doc_freq]
|
|
364
|
+
hash["mlt.minwl"] = @params[:mlt][:min_word_length]
|
|
365
|
+
hash["mlt.maxwl"] = @params[:mlt][:max_word_length]
|
|
366
|
+
hash["mlt.maxqt"] = @params[:mlt][:max_query_terms]
|
|
367
|
+
hash["mlt.maxntp"] = @params[:mlt][:max_tokens_parsed]
|
|
368
|
+
hash["mlt.boost"] = @params[:mlt][:boost]
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
hash.merge(super.to_hash)
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
2
|
+
# (the "License"); you may not use this file except in compliance with
|
|
3
|
+
# the License. You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and
|
|
11
|
+
# limitations under the License.
|
|
12
|
+
|
|
13
|
+
# a parent class for all requests that go through the solr update handler
|
|
14
|
+
# TODO: Use new xml update handler for better error responses
|
|
15
|
+
class Solr::Request::Update < Solr::Request::Base
|
|
16
|
+
def response_format
|
|
17
|
+
:xml
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def handler
|
|
21
|
+
'update'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
2
|
+
# (the "License"); you may not use this file except in compliance with
|
|
3
|
+
# the License. You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and
|
|
11
|
+
# limitations under the License.
|
|
12
|
+
|
|
13
|
+
module Solr; module Response; end; end
|
|
14
|
+
require 'solr/response/base'
|
|
15
|
+
require 'solr/response/xml'
|
|
16
|
+
require 'solr/response/ruby'
|
|
17
|
+
require 'solr/response/ping'
|
|
18
|
+
require 'solr/response/add_document'
|
|
19
|
+
require 'solr/response/modify_document'
|
|
20
|
+
require 'solr/response/standard'
|
|
21
|
+
require 'solr/response/spellcheck'
|
|
22
|
+
require 'solr/response/dismax'
|
|
23
|
+
require 'solr/response/commit'
|
|
24
|
+
require 'solr/response/delete'
|
|
25
|
+
require 'solr/response/index_info'
|
|
26
|
+
require 'solr/response/optimize'
|
|
27
|
+
require 'solr/response/select'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
2
|
+
# (the "License"); you may not use this file except in compliance with
|
|
3
|
+
# the License. You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and
|
|
11
|
+
# limitations under the License.
|
|
12
|
+
|
|
13
|
+
class Solr::Response::AddDocument < Solr::Response::Xml
|
|
14
|
+
def initialize(xml)
|
|
15
|
+
super
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
2
|
+
# (the "License"); you may not use this file except in compliance with
|
|
3
|
+
# the License. You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and
|
|
11
|
+
# limitations under the License.
|
|
12
|
+
|
|
13
|
+
class Solr::Response::Base
|
|
14
|
+
attr_reader :raw_response
|
|
15
|
+
|
|
16
|
+
def initialize(raw_response)
|
|
17
|
+
@raw_response = raw_response
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# factory method for creating a Solr::Response::* from
|
|
21
|
+
# a request and the raw response content
|
|
22
|
+
def self.make_response(request, raw)
|
|
23
|
+
|
|
24
|
+
# make sure response format seems sane
|
|
25
|
+
unless [:xml, :ruby].include?(request.response_format)
|
|
26
|
+
raise Solr::Exception.new("unknown response format: #{request.response_format}" )
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# TODO: Factor out this case... perhaps the request object should provide the response class instead? Or dynamically align by class name?
|
|
30
|
+
# Maybe the request itself could have the response handling features that get mixed in with a single general purpose response object?
|
|
31
|
+
|
|
32
|
+
begin
|
|
33
|
+
klass = eval(request.class.name.sub(/Request/,'Response'))
|
|
34
|
+
rescue NameError
|
|
35
|
+
raise Solr::Exception.new("unknown request type: #{request.class}")
|
|
36
|
+
else
|
|
37
|
+
klass.new(raw)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|