@Override
 public void toXContent(XContentBuilder builder, Params params) throws IOException {
   hits.toXContent(builder, params);
   if (facets != null) {
     facets.toXContent(builder, params);
   }
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   hits = readSearchHits(in);
   if (in.readBoolean()) {
     facets = InternalFacets.readFacets(in);
   }
   timedOut = in.readBoolean();
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   hits.writeTo(out);
   if (facets == null) {
     out.writeBoolean(false);
   } else {
     out.writeBoolean(true);
     facets.writeTo(out);
   }
   out.writeBoolean(timedOut);
 }