onemorecloud-websolr-rails 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +15 -0
- data/LICENSE +19 -0
- data/README.rdoc +69 -0
- data/Rakefile +112 -0
- data/TESTING_THE_PLUGIN +25 -0
- data/VERSION +1 -0
- data/bin/websolr +8 -0
- data/config/solr.yml +15 -0
- data/config/solr_environment.rb +22 -0
- data/generate_rdoc.sh +13 -0
- data/lib/acts_as_solr.rb +59 -0
- data/lib/acts_methods.rb +279 -0
- data/lib/class_methods.rb +239 -0
- data/lib/common_methods.rb +89 -0
- data/lib/deprecation.rb +61 -0
- data/lib/instance_methods.rb +166 -0
- data/lib/lazy_document.rb +18 -0
- data/lib/parser_methods.rb +201 -0
- data/lib/search_results.rb +68 -0
- data/lib/solr.rb +21 -0
- data/lib/solr/connection.rb +179 -0
- data/lib/solr/document.rb +78 -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 +402 -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 +8 -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 +44 -0
- data/lib/solr_fixtures.rb +13 -0
- data/lib/tasks/database.rake +18 -0
- data/lib/tasks/solr.rake +137 -0
- data/lib/tasks/test.rake +7 -0
- data/lib/websolr-rails.rb +1 -0
- data/lib/websolr.rb +1 -0
- data/lib/websolr_controller.rb +132 -0
- data/lib/websolr_option_parser.rb +58 -0
- data/lib/websolr_rails.rb +1 -0
- data/lib/websolr_rails/tasks.rb +4 -0
- data/solr/CHANGES.txt +1207 -0
- data/solr/LICENSE.txt +712 -0
- data/solr/NOTICE.txt +90 -0
- data/solr/etc/jetty.xml +205 -0
- data/solr/etc/webdefault.xml +379 -0
- data/solr/lib/easymock.jar +0 -0
- data/solr/lib/jetty-6.1.3.jar +0 -0
- data/solr/lib/jetty-util-6.1.3.jar +0 -0
- data/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
- data/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
- data/solr/lib/servlet-api-2.4.jar +0 -0
- data/solr/lib/servlet-api-2.5-6.1.3.jar +0 -0
- data/solr/lib/xpp3-1.1.3.4.O.jar +0 -0
- data/solr/logs/.empty-dir-for-git +0 -0
- data/solr/solr/README.txt +52 -0
- data/solr/solr/bin/abc +176 -0
- data/solr/solr/bin/abo +176 -0
- data/solr/solr/bin/backup +108 -0
- data/solr/solr/bin/backupcleaner +142 -0
- data/solr/solr/bin/commit +128 -0
- data/solr/solr/bin/optimize +129 -0
- data/solr/solr/bin/readercycle +129 -0
- data/solr/solr/bin/rsyncd-disable +77 -0
- data/solr/solr/bin/rsyncd-enable +76 -0
- data/solr/solr/bin/rsyncd-start +145 -0
- data/solr/solr/bin/rsyncd-stop +105 -0
- data/solr/solr/bin/scripts-util +83 -0
- data/solr/solr/bin/snapcleaner +148 -0
- data/solr/solr/bin/snapinstaller +168 -0
- data/solr/solr/bin/snappuller +248 -0
- data/solr/solr/bin/snappuller-disable +77 -0
- data/solr/solr/bin/snappuller-enable +77 -0
- data/solr/solr/bin/snapshooter +109 -0
- data/solr/solr/conf/admin-extra.html +31 -0
- data/solr/solr/conf/protwords.txt +21 -0
- data/solr/solr/conf/schema.xml +126 -0
- data/solr/solr/conf/scripts.conf +24 -0
- data/solr/solr/conf/solrconfig.xml +458 -0
- data/solr/solr/conf/stopwords.txt +57 -0
- data/solr/solr/conf/synonyms.txt +31 -0
- data/solr/solr/conf/xslt/example.xsl +132 -0
- data/solr/solr/conf/xslt/example_atom.xsl +63 -0
- data/solr/solr/conf/xslt/example_rss.xsl +62 -0
- data/solr/start.jar +0 -0
- data/solr/tmp/.empty-dir-for-git +0 -0
- data/solr/webapps/solr.war +0 -0
- data/test/config/solr.yml +2 -0
- data/test/db/connections/mysql/connection.rb +10 -0
- data/test/db/connections/sqlite/connection.rb +8 -0
- data/test/db/migrate/001_create_books.rb +15 -0
- data/test/db/migrate/002_create_movies.rb +12 -0
- data/test/db/migrate/003_create_categories.rb +11 -0
- data/test/db/migrate/004_create_electronics.rb +16 -0
- data/test/db/migrate/005_create_authors.rb +12 -0
- data/test/db/migrate/006_create_postings.rb +9 -0
- data/test/db/migrate/007_create_posts.rb +13 -0
- data/test/db/migrate/008_create_gadgets.rb +11 -0
- data/test/fixtures/authors.yml +9 -0
- data/test/fixtures/books.yml +13 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/db_definitions/mysql.sql +41 -0
- data/test/fixtures/electronics.yml +49 -0
- data/test/fixtures/movies.yml +9 -0
- data/test/fixtures/postings.yml +10 -0
- data/test/functional/acts_as_solr_test.rb +413 -0
- data/test/functional/association_indexing_test.rb +37 -0
- data/test/functional/faceted_search_test.rb +163 -0
- data/test/functional/multi_solr_search_test.rb +51 -0
- data/test/models/author.rb +10 -0
- data/test/models/book.rb +10 -0
- data/test/models/category.rb +8 -0
- data/test/models/electronic.rb +21 -0
- data/test/models/gadget.rb +9 -0
- data/test/models/movie.rb +17 -0
- data/test/models/novel.rb +2 -0
- data/test/models/post.rb +3 -0
- data/test/models/posting.rb +11 -0
- data/test/test_helper.rb +51 -0
- data/test/unit/acts_methods_shoulda.rb +70 -0
- data/test/unit/class_methods_shoulda.rb +88 -0
- data/test/unit/common_methods_shoulda.rb +112 -0
- data/test/unit/instance_methods_shoulda.rb +326 -0
- data/test/unit/lazy_document_shoulda.rb +35 -0
- data/test/unit/parser_instance.rb +19 -0
- data/test/unit/parser_methods_shoulda.rb +278 -0
- data/test/unit/solr_instance.rb +46 -0
- data/test/unit/test_helper.rb +14 -0
- data/websolr-rails.gemspec +241 -0
- metadata +263 -0
@@ -0,0 +1,402 @@
|
|
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, :date_facets,
|
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
|
+
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] = sort ? "#{@params[:query]};#{sort}" : @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
|
+
if @params[:facets][:fields] # facet fields are optional (could be facet.query only)
|
79
|
+
@params[:facets][:fields].each do |f|
|
80
|
+
if f.kind_of? Hash
|
81
|
+
key = f.keys[0]
|
82
|
+
value = f[key]
|
83
|
+
hash["facet.field"] << key
|
84
|
+
hash["f.#{key}.facet.sort"] = (value[:sort] == :count) if value[:sort]
|
85
|
+
hash["f.#{key}.facet.limit"] = value[:limit]
|
86
|
+
hash["f.#{key}.facet.missing"] = value[:missing]
|
87
|
+
hash["f.#{key}.facet.mincount"] = value[:mincount]
|
88
|
+
hash["f.#{key}.facet.prefix"] = value[:prefix]
|
89
|
+
hash["f.#{key}.facet.offset"] = value[:offset]
|
90
|
+
else
|
91
|
+
hash["facet.field"] << f
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
if @params[:date_facets]
|
97
|
+
hash["facet.date"] = []
|
98
|
+
if @params[:date_facets][:fields]
|
99
|
+
@params[:date_facets][:fields].each do |f|
|
100
|
+
if f.kind_of? Hash
|
101
|
+
key = f.keys[0]
|
102
|
+
hash["facet.date"] << key
|
103
|
+
f[key].each { |k, v|
|
104
|
+
hash["f.#{key}.facet.date.#{k}"] = v
|
105
|
+
}
|
106
|
+
else
|
107
|
+
hash["facet.date"] << f
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
hash["facet.date.start"] = @params[:date_facets][:start]
|
112
|
+
hash["facet.date.end"] = @params[:date_facets][:end]
|
113
|
+
hash["facet.date.gap"] = @params[:date_facets][:gap]
|
114
|
+
hash["facet.date.other"] = @params[:date_facets][:other]
|
115
|
+
hash["facet.date.hardend"] = @params[:date_facets][:hardend]
|
116
|
+
if @params[:date_facets][:filter]
|
117
|
+
if hash[:fq]
|
118
|
+
hash[:fq] << @params[:date_facets][:filter]
|
119
|
+
else
|
120
|
+
hash[:fq] = @params[:date_facets][:filter]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# highlighting parameter processing - http://wiki.apache.org/solr/HighlightingParameters
|
127
|
+
if @params[:highlighting]
|
128
|
+
hash[:hl] = true
|
129
|
+
hash["hl.fl"] = @params[:highlighting][:field_list].join(',') if @params[:highlighting][:field_list]
|
130
|
+
|
131
|
+
snippets = @params[:highlighting][:max_snippets]
|
132
|
+
if snippets
|
133
|
+
if snippets.kind_of? Hash
|
134
|
+
if snippets[:default]
|
135
|
+
hash["hl.snippets"] = snippets[:default]
|
136
|
+
end
|
137
|
+
if snippets[:fields]
|
138
|
+
snippets[:fields].each do |k,v|
|
139
|
+
hash["f.#{k}.hl.snippets"] = v
|
140
|
+
end
|
141
|
+
end
|
142
|
+
else
|
143
|
+
hash["hl.snippets"] = snippets
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
fragsize = @params[:highlighting][:fragment_size]
|
148
|
+
if fragsize
|
149
|
+
if fragsize.kind_of? Hash
|
150
|
+
if fragsize[:default]
|
151
|
+
hash["hl.fragsize"] = fragsize[:default]
|
152
|
+
end
|
153
|
+
if fragsize[:fields]
|
154
|
+
fragsize[:fields].each do |k,v|
|
155
|
+
hash["f.#{k}.hl.fragsize"] = v
|
156
|
+
end
|
157
|
+
end
|
158
|
+
else
|
159
|
+
hash["hl.fragsize"] = fragsize
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
rfm = @params[:highlighting][:require_field_match]
|
164
|
+
if nil != rfm
|
165
|
+
if rfm.kind_of? Hash
|
166
|
+
if nil != rfm[:default]
|
167
|
+
hash["hl.requireFieldMatch"] = rfm[:default]
|
168
|
+
end
|
169
|
+
if rfm[:fields]
|
170
|
+
rfm[:fields].each do |k,v|
|
171
|
+
hash["f.#{k}.hl.requireFieldMatch"] = v
|
172
|
+
end
|
173
|
+
end
|
174
|
+
else
|
175
|
+
hash["hl.requireFieldMatch"] = rfm
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
mac = @params[:highlighting][:max_analyzed_chars]
|
180
|
+
if mac
|
181
|
+
if mac.kind_of? Hash
|
182
|
+
if mac[:default]
|
183
|
+
hash["hl.maxAnalyzedChars"] = mac[:default]
|
184
|
+
end
|
185
|
+
if mac[:fields]
|
186
|
+
mac[:fields].each do |k,v|
|
187
|
+
hash["f.#{k}.hl.maxAnalyzedChars"] = v
|
188
|
+
end
|
189
|
+
end
|
190
|
+
else
|
191
|
+
hash["hl.maxAnalyzedChars"] = mac
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
prefix = @params[:highlighting][:prefix]
|
196
|
+
if prefix
|
197
|
+
if prefix.kind_of? Hash
|
198
|
+
if prefix[:default]
|
199
|
+
hash["hl.simple.pre"] = prefix[:default]
|
200
|
+
end
|
201
|
+
if prefix[:fields]
|
202
|
+
prefix[:fields].each do |k,v|
|
203
|
+
hash["f.#{k}.hl.simple.pre"] = v
|
204
|
+
end
|
205
|
+
end
|
206
|
+
else
|
207
|
+
hash["hl.simple.pre"] = prefix
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
suffix = @params[:highlighting][:suffix]
|
212
|
+
if suffix
|
213
|
+
if suffix.kind_of? Hash
|
214
|
+
if suffix[:default]
|
215
|
+
hash["hl.simple.post"] = suffix[:default]
|
216
|
+
end
|
217
|
+
if suffix[:fields]
|
218
|
+
suffix[:fields].each do |k,v|
|
219
|
+
hash["f.#{k}.hl.simple.post"] = v
|
220
|
+
end
|
221
|
+
end
|
222
|
+
else
|
223
|
+
hash["hl.simple.post"] = suffix
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
formatter = @params[:highlighting][:formatter]
|
228
|
+
if formatter
|
229
|
+
if formatter.kind_of? Hash
|
230
|
+
if formatter[:default]
|
231
|
+
hash["hl.formatter"] = formatter[:default]
|
232
|
+
end
|
233
|
+
if formatter[:fields]
|
234
|
+
formatter[:fields].each do |k,v|
|
235
|
+
hash["f.#{k}.hl.formatter"] = v
|
236
|
+
end
|
237
|
+
end
|
238
|
+
else
|
239
|
+
hash["hl.formatter"] = formatter
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
fragmenter = @params[:highlighting][:fragmenter]
|
244
|
+
if fragmenter
|
245
|
+
if fragmenter.kind_of? Hash
|
246
|
+
if fragmenter[:default]
|
247
|
+
hash["hl.fragmenter"] = fragmenter[:default]
|
248
|
+
end
|
249
|
+
if fragmenter[:fields]
|
250
|
+
fragmenter[:fields].each do |k,v|
|
251
|
+
hash["f.#{k}.hl.fragmenter"] = v
|
252
|
+
end
|
253
|
+
end
|
254
|
+
else
|
255
|
+
hash["hl.fragmenter"] = fragmenter
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
merge_contiguous = @params[:highlighting][:merge_contiguous]
|
260
|
+
if nil != merge_contiguous
|
261
|
+
if merge_contiguous.kind_of? Hash
|
262
|
+
if nil != merge_contiguous[:default]
|
263
|
+
hash["hl.mergeContiguous"] = merge_contiguous[:default]
|
264
|
+
end
|
265
|
+
if merge_contiguous[:fields]
|
266
|
+
merge_contiguous[:fields].each do |k,v|
|
267
|
+
hash["f.#{k}.hl.mergeContiguous"] = v
|
268
|
+
end
|
269
|
+
end
|
270
|
+
else
|
271
|
+
hash["hl.mergeContiguous"] = merge_contiguous
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
increment = @params[:highlighting][:increment]
|
276
|
+
if increment
|
277
|
+
if increment.kind_of? Hash
|
278
|
+
if increment[:default]
|
279
|
+
hash["hl.increment"] = increment[:default]
|
280
|
+
end
|
281
|
+
if increment[:fields]
|
282
|
+
increment[:fields].each do |k,v|
|
283
|
+
hash["f.#{k}.hl.increment"] = v
|
284
|
+
end
|
285
|
+
end
|
286
|
+
else
|
287
|
+
hash["hl.increment"] = increment
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
# support "old style"
|
292
|
+
alternate_fields = @params[:highlighting][:alternate_fields]
|
293
|
+
if alternate_fields
|
294
|
+
alternate_fields.each do |f,v|
|
295
|
+
hash["f.#{f}.hl.alternateField"] = v
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
alternate_field = @params[:highlighting][:alternate_field]
|
300
|
+
if alternate_field
|
301
|
+
if alternate_field.kind_of? Hash
|
302
|
+
if alternate_field[:default]
|
303
|
+
hash["hl.alternateField"] = alternate_field[:default]
|
304
|
+
end
|
305
|
+
if alternate_field[:fields]
|
306
|
+
alternate_field[:fields].each do |k,v|
|
307
|
+
hash["f.#{k}.hl.alternateField"] = v
|
308
|
+
end
|
309
|
+
end
|
310
|
+
else
|
311
|
+
hash["hl.alternateField"] = alternate_field
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
mafl = @params[:highlighting][:max_alternate_field_length]
|
316
|
+
if mafl
|
317
|
+
if mafl.kind_of? Hash
|
318
|
+
if mafl[:default]
|
319
|
+
hash["hl.maxAlternateFieldLength"] = mafl[:default]
|
320
|
+
end
|
321
|
+
if mafl[:fields]
|
322
|
+
mafl[:fields].each do |k,v|
|
323
|
+
hash["f.#{k}.hl.maxAlternateFieldLength"] = v
|
324
|
+
end
|
325
|
+
else
|
326
|
+
# support "old style"
|
327
|
+
mafl.each do |k,v|
|
328
|
+
hash["f.#{k}.hl.maxAlternateFieldLength"] = v
|
329
|
+
end
|
330
|
+
end
|
331
|
+
else
|
332
|
+
hash["hl.maxAlternateFieldLength"] = mafl
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
hash["hl.usePhraseHighlighter"] = @params[:highlighting][:use_phrase_highlighter]
|
337
|
+
|
338
|
+
regex = @params[:highlighting][:regex]
|
339
|
+
if regex
|
340
|
+
if regex[:slop]
|
341
|
+
if regex[:slop].kind_of? Hash
|
342
|
+
if regex[:slop][:default]
|
343
|
+
hash["hl.regex.slop"] = regex[:slop][:default]
|
344
|
+
end
|
345
|
+
if regex[:slop][:fields]
|
346
|
+
regex[:slop][:fields].each do |k,v|
|
347
|
+
hash["f.#{k}.hl.regex.slop"] = v
|
348
|
+
end
|
349
|
+
end
|
350
|
+
else
|
351
|
+
hash["hl.regex.slop"] = regex[:slop]
|
352
|
+
end
|
353
|
+
end
|
354
|
+
if regex[:pattern]
|
355
|
+
if regex[:pattern].kind_of? Hash
|
356
|
+
if regex[:pattern][:default]
|
357
|
+
hash["hl.regex.pattern"] = regex[:pattern][:default]
|
358
|
+
end
|
359
|
+
if regex[:pattern][:fields]
|
360
|
+
regex[:pattern][:fields].each do |k,v|
|
361
|
+
hash["f.#{k}.hl.regex.pattern"] = v
|
362
|
+
end
|
363
|
+
end
|
364
|
+
else
|
365
|
+
hash["hl.regex.pattern"] = regex[:pattern]
|
366
|
+
end
|
367
|
+
end
|
368
|
+
if regex[:max_analyzed_chars]
|
369
|
+
if regex[:max_analyzed_chars].kind_of? Hash
|
370
|
+
if regex[:max_analyzed_chars][:default]
|
371
|
+
hash["hl.regex.maxAnalyzedChars"] = regex[:max_analyzed_chars][:default]
|
372
|
+
end
|
373
|
+
if regex[:max_analyzed_chars][:fields]
|
374
|
+
regex[:max_analyzed_chars][:fields].each do |k,v|
|
375
|
+
hash["f.#{k}.hl.regex.maxAnalyzedChars"] = v
|
376
|
+
end
|
377
|
+
end
|
378
|
+
else
|
379
|
+
hash["hl.regex.maxAnalyzedChars"] = regex[:max_analyzed_chars]
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
end
|
385
|
+
|
386
|
+
if @params[:mlt]
|
387
|
+
hash[:mlt] = true
|
388
|
+
hash["mlt.count"] = @params[:mlt][:count]
|
389
|
+
hash["mlt.fl"] = @params[:mlt][:field_list].join(',')
|
390
|
+
hash["mlt.mintf"] = @params[:mlt][:min_term_freq]
|
391
|
+
hash["mlt.mindf"] = @params[:mlt][:min_doc_freq]
|
392
|
+
hash["mlt.minwl"] = @params[:mlt][:min_word_length]
|
393
|
+
hash["mlt.maxwl"] = @params[:mlt][:max_word_length]
|
394
|
+
hash["mlt.maxqt"] = @params[:mlt][:max_query_terms]
|
395
|
+
hash["mlt.maxntp"] = @params[:mlt][:max_tokens_parsed]
|
396
|
+
hash["mlt.boost"] = @params[:mlt][:boost]
|
397
|
+
end
|
398
|
+
|
399
|
+
hash.merge(super.to_hash)
|
400
|
+
end
|
401
|
+
|
402
|
+
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'
|