code: @Override
    public void writeTo(StreamOutput out) throws IOException {
      super.writeTo(out);
  
      out.writeOptionalString(routing);
      out.writeOptionalString(preference);
  
      if (querySource != null) {
        out.writeBoolean(true);
        out.writeBytesReference(querySource);
      } else {
        out.writeBoolean(false);
      }
  
      if (types == null) {
        out.writeBoolean(false);
      } else {
        out.writeBoolean(true);
        out.writeStringArray(types);
      }
  
      out.writeString(field);
      out.writeVLong(nowInMillis);
  
      if (ordering == null) {
        out.writeBoolean(false);
      } else {
        out.writeBoolean(true);
        out.writeVInt(ordering.ordinal());
      }
  
      if (maxTermsPerShard == null) {
        out.writeBoolean(false);
      } else {
        out.writeBoolean(true);
        out.writeVInt(maxTermsPerShard);
      }
  
      if (termsEncoding == null) {
        out.writeBoolean(false);
      } else {
        out.writeBoolean(true);
        out.writeVInt(termsEncoding.ordinal());
      }
  
      if (expectedTerms == null) {
        out.writeBoolean(false);
      }
      else {
        out.writeBoolean(true);
        out.writeVLong(expectedTerms);
      }
    }
docs: Serialize
  
  @param out the output
  @throws IOException