for( Object o : doc.getFields() ) {
Fieldable fieldable = (Fieldable)o;
SimpleOrderedMap<Object> f = new SimpleOrderedMap<Object>();
SchemaField sfield = schema.getFieldOrNull( fieldable.name() );
FieldType ftype = (sfield==null)?null:sfield.getType();
f.add( "type", (ftype==null)?null:ftype.getTypeName() );
f.add( "schema", getFieldFlags( sfield ) );
f.add( "flags", getFieldFlags( fieldable ) );
Term t = new Term(fieldable.name(), ftype!=null ? ftype.storedToIndexed(fieldable) : fieldable.stringValue());
f.add( "value", (ftype==null)?null:ftype.toExternal( fieldable ) );
// TODO: this really should be "stored"
f.add( "internal", fieldable.stringValue() ); // may be a binary number
byte[] arr = fieldable.getBinaryValue();