def to_solr_doc
      debug "to_solr_doc: creating doc for class: #{self.class.name}, id: #{record_id(self)}"
      doc = Solr::Document.new
      doc.boost = validate_boost(configuration[:boost]) if configuration[:boost]
      
      doc << {:id => solr_id,
              solr_configuration[:type_field] => self.class.name,
              solr_configuration[:primary_key_field] => record_id(self).to_s}

      # iterate through the fields and add them to the document,
      configuration[:solr_fields].each do |field_name, options|
        next if [self.class.primary_key, "type"].include?(field_name.to_s)

        field_boost = options[:boost] || solr_configuration[:default_boost]
        field_type = get_solr_field_type(options[:type])
        solr_name = options[:as] || field_name
        
        value = self.send("#{field_name}_for_solr") rescue nil
        next if value.nil?

        suffix = get_solr_field_type(field_type)
        value = Array(value).map{ |v| ERB::Util.html_escape(v) } # escape each value
        value = value.first if value.size == 1

        field = Solr::Field.new(:name => "#{solr_name}_#{suffix}", :value => value)
        processed_boost = validate_boost(field_boost)
        field.boost = processed_boost
        doc << field
      end
      
      add_dynamic_attributes(doc)
      add_includes(doc)
      add_tags(doc)
      add_space(doc)
      
      debug doc.to_json
      doc
    end
def to_solr_doc
      debug "to_solr_doc: creating doc for class: #{self.class.name}, id: #{record_id(self)}"
      doc = Solr::Document.new
      doc.boost = validate_boost(configuration[:boost]) if configuration[:boost]
      
      doc << {:id => solr_id,
              solr_configuration[:type_field] => self.class.name,
              solr_configuration[:primary_key_field] => record_id(self).to_s}

      # iterate through the fields and add them to the document,
      configuration[:solr_fields].each do |field_name, options|
        next if [self.class.primary_key, "type"].include?(field_name.to_s)

        field_boost = options[:boost] || solr_configuration[:default_boost]
        field_type = get_solr_field_type(options[:type])
        solr_name = options[:as] || field_name
        
        value = self.send("#{field_name}_for_solr") rescue nil
        next if value.nil?

        suffix = get_solr_field_type(field_type)
        value = Array(value).map{ |v| ERB::Util.html_escape(v) } # escape each value
        value = value.first if value.size == 1

        field = Solr::Field.new(:name => "#{solr_name}_#{suffix}", :value => value)
        processed_boost = validate_boost(field_boost)
        field.boost = processed_boost
        doc << field
      end
      
      add_dynamic_attributes(doc)
      add_includes(doc)
      add_tags(doc)
      add_space(doc)
      
      debug doc.to_json
      doc
    end
convert instance to Solr document