public byte[] buildAsBytes(XContentType contentType) throws SearchSourceBuilderException {
   try {
     XContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
     toXContent(builder, EMPTY_PARAMS);
     return builder.copiedBytes();
   } catch (Exception e) {
     throw new SearchSourceBuilderException("Failed to build search source", e);
   }
 }