class Solr::Field
Constants
- VALID_PARAMS
Attributes
boost[RW]
name[RW]
value[RW]
Public Class Methods
new(params)
click to toggle source
Accepts an optional :boost
parameter, used to boost the relevance of a particular field.
# File lib/solr/field.rb, line 23 def initialize(params) @boost = params[:boost] name_key = (params.keys - VALID_PARAMS).first @name, @value = name_key.to_s, params[name_key] # Convert any Time values into UTC/XML schema format (which Solr requires). @value = @value.respond_to?(:utc) ? @value.utc.xmlschema : @value.to_s end
Public Instance Methods
to_xml()
click to toggle source
# File lib/solr/field.rb, line 31 def to_xml e = Solr::XML::Element.new 'field' e.attributes['name'] = @name e.attributes['boost'] = @boost.to_s if @boost e.text = @value return e end