code: private static Field readField(ObjectInput in, Document doc) throws IOException, ClassNotFoundException
     {
        String name = in.readUTF();
        int flags = in.readInt();
        float boost = (flags & BOOST_FLAG) > 0 ? in.readFloat() : 1.0f;
        Object value = in.readObject();
        Field field;
        if (value instanceof TokenStream)
        {
           field = new Field(name, (TokenStream)value, getTermVectorParameter(flags));
        }
        else
        {
           // The value is a String
           field =
              new Field(name, (String)value, getStoreParameter(flags), getIndexParameter(flags),
                 getTermVectorParameter(flags));
        }
        field.setBoost(boost);
        field.setOmitNorms((flags & OMIT_NORMS_FLAG) > 0);
        IndexOptions indexOptions;
        if ((flags & OMIT_TF_FLAG) > 0) {
           indexOptions = IndexOptions.DOCS_ONLY;
         } else {
           indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
         }
        field.setIndexOptions(indexOptions);
        return field;
     }
docs: Deserialize the field from the given {@link ObjectInput}
  @param in the stream from which we deserialize the Field
  @return the deserialized field
  @throws IOException
  @throws ClassNotFoundException