mirror of https://github.com/apache/lucene.git
Allow field hash to take an array for values
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@496797 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
162dbee7ea
commit
5e4dcfa889
|
@ -36,7 +36,9 @@ module Solr
|
|||
def <<(fields)
|
||||
case fields
|
||||
when Hash
|
||||
fields.each_pair {|k,v| @fields << Solr::Field.new(k => v)}
|
||||
fields.each_pair do |name,value|
|
||||
value.each {|v| @fields << Solr::Field.new(name => v)}
|
||||
end
|
||||
when Solr::Field
|
||||
@fields << fields
|
||||
else
|
||||
|
|
|
@ -31,6 +31,11 @@ class DocumentTest < Test::Unit::TestCase
|
|||
assert_equal "<doc><field name='creator'>Erik Hatcher</field><field name='creator'>Otis Gospodnetic</field></doc>", doc.to_xml.to_s
|
||||
end
|
||||
|
||||
def test_repeatable_in_hash
|
||||
doc = Solr::Document.new({:creator => ['Erik Hatcher', 'Otis Gospodnetic']})
|
||||
assert_equal "<doc><field name='creator'>Erik Hatcher</field><field name='creator'>Otis Gospodnetic</field></doc>", doc.to_xml.to_s
|
||||
end
|
||||
|
||||
def test_bad_doc
|
||||
doc = Solr::Document.new
|
||||
assert_raise(RuntimeError) do
|
||||
|
|
Loading…
Reference in New Issue