def mkterm type, *args
    case type
    when :label
      PREFIX['label'][:prefix] + args[0].to_s.downcase
    when :type
      PREFIX['type'][:prefix] + args[0].to_s.downcase
    when :date
      PREFIX['date'][:prefix] + args[0].getutc.strftime("%Y%m%d%H%M%S")
    when :email
      case args[0]
      when :from then PREFIX['from_email'][:prefix]
      when :to then PREFIX['to_email'][:prefix]
      else raise "Invalid email term type #{args[0]}"
      end + args[1].to_s.downcase
    when :source_id
      PREFIX['source_id'][:prefix] + args[0].to_s.downcase
    when :location
      PREFIX['location'][:prefix] + [args[0]].pack('n') + args[1].to_s
    when :attachment_extension
      PREFIX['attachment_extension'][:prefix] + args[0].to_s.downcase
    when :msgid, :ref, :thread
      PREFIX[type.to_s][:prefix] + args[0][0...(MAX_TERM_LENGTH-1)]
    else
      raise "Invalid term type #{type}"
    end
  end
def mkterm type, *args
    case type
    when :label
      PREFIX['label'][:prefix] + args[0].to_s.downcase
    when :type
      PREFIX['type'][:prefix] + args[0].to_s.downcase
    when :date
      PREFIX['date'][:prefix] + args[0].getutc.strftime("%Y%m%d%H%M%S")
    when :email
      case args[0]
      when :from then PREFIX['from_email'][:prefix]
      when :to then PREFIX['to_email'][:prefix]
      else raise "Invalid email term type #{args[0]}"
      end + args[1].to_s.downcase
    when :source_id
      PREFIX['source_id'][:prefix] + args[0].to_s.downcase
    when :location
      PREFIX['location'][:prefix] + [args[0]].pack('n') + args[1].to_s
    when :attachment_extension
      PREFIX['attachment_extension'][:prefix] + args[0].to_s.downcase
    when :msgid, :ref, :thread
      PREFIX[type.to_s][:prefix] + args[0][0...(MAX_TERM_LENGTH-1)]
    else
      raise "Invalid term type #{type}"
    end
  end
Construct a Xapian term