Class: Solr::Document
- Inherits:
-
Object
- Object
- Solr::Document
- Includes:
- Enumerable
- Defined in:
- lib/solr/document.rb
Instance Attribute Summary collapse
-
#boost ⇒ Object
Returns the value of attribute boost.
Instance Method Summary collapse
-
#<<(fields) ⇒ Object
Append a Solr::Field.
-
#[](name) ⇒ Object
shorthand to allow hash lookups doc.
-
#[]=(name, value) ⇒ Object
shorthand to assign as a hash.
-
#initialize(hash = {}) ⇒ Document
constructor
Create a new Solr::Document, optionally passing in a hash of key/value pairs for the fields.
-
#to_xml ⇒ Object
convert the Document to a REXML::Element.
Constructor Details
Instance Attribute Details
#boost ⇒ Object
Returns the value of attribute boost.
18 19 20 |
# File 'lib/solr/document.rb', line 18 def boost @boost end |
Instance Method Details
#<<(fields) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/solr/document.rb', line 36 def <<(fields) case fields when Hash fields.each_pair do |name,value| if value.respond_to?(:each) && !value.is_a?(String) value.each {|v| @fields << Solr::Field.new(name => v)} else @fields << Solr::Field.new(name => value) end end when Solr::Field @fields << fields else raise "must pass in Solr::Field or Hash" end end |
#[](name) ⇒ Object
shorthand to allow hash lookups
doc['name']
55 56 57 58 59 |
# File 'lib/solr/document.rb', line 55 def [](name) field = @fields.find {|f| f.name == name.to_s} return field.value if field return nil end |