@Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeByte(percolatorTypeId);
   out.writeVLong(requestedSize);
   out.writeVLong(count);
   out.writeVInt(matches.length);
   for (BytesRef match : matches) {
     out.writeBytesRef(match);
   }
   out.writeVLong(scores.length);
   for (float score : scores) {
     out.writeFloat(score);
   }
   out.writeVInt(hls.size());
   for (Map<String, HighlightField> hl : hls) {
     out.writeVInt(hl.size());
     for (Map.Entry<String, HighlightField> entry : hl.entrySet()) {
       out.writeString(entry.getKey());
       entry.getValue().writeTo(out);
     }
   }
   out.writeOptionalStreamable(aggregations);
   if (pipelineAggregators == null) {
     out.writeBoolean(false);
   } else {
     out.writeBoolean(true);
     out.writeVInt(pipelineAggregators.size());
     for (PipelineAggregator pipelineAggregator : pipelineAggregators) {
       out.writeBytesReference(pipelineAggregator.type().stream());
       pipelineAggregator.writeTo(out);
     }
   }
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeByte(stage.value());
   stats.writeTo(out);
   out.writeOptionalString(nodeId);
   out.writeOptionalString(failure);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeVInt(fieldStats.size());
   for (Map.Entry<String, FieldStats<?>> entry : fieldStats.entrySet()) {
     out.writeString(entry.getKey());
     entry.getValue().writeTo(out);
   }
 }