15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/sunspot/rich_document.rb', line 15
def add(connection)
params = {
:wt => :ruby
}
data = nil
@fields.each do |f|
if f.name.to_s.include?("_attachment") and f.value.present?
params['fmap.content'] = f.name
if f.value.is_a?(Hash)
params['stream.url'] = f.value[:file]
params['stream.contentType'] = f.value[:type]
else
data = open(f.value).read rescue ""
end
else
param_name = "literal.#{f.name.to_s}"
params[param_name] = [] unless params.has_key?(param_name)
params[param_name] << f.value
end
if f.attrs[:boost]
params["boost.#{f.name.to_s}"] = f.attrs[:boost]
end
end
connection.send_and_receive('update/extract',
{ :method => :post,
:params => params,
:data => data,
:headers => {"Content-Type" => ""}
})
end
|