code: public <T> SearchResult<T> querySearchResult(String query, Class<T> classOfT) {
          InputStream instream = null;
          try {
              Reader reader = new InputStreamReader(instream = queryForStream(query), "UTF-8");
              JsonObject json = new JsonParser().parse(reader).getAsJsonObject();
              SearchResult<T> sr = new SearchResult<T>();
              sr.setTotalRows(getAsLong(json, "total_rows"));
              sr.setBookmark(getAsString(json, "bookmark"));
              if (json.has("rows")) {
                  sr.setRows(getRows(json.getAsJsonArray("rows"), sr, classOfT));
              } else if (json.has("groups")) {
                  setGroups(json.getAsJsonArray("groups"), sr, classOfT);
              }
  
              if (json.has("counts")) {
                  sr.setCounts(getFieldsCounts(json.getAsJsonObject("counts").entrySet()));
              }
  
              if (json.has("ranges")) {
                  sr.setRanges(getFieldsCounts(json.getAsJsonObject("ranges").entrySet()));
              }
              return sr;
          } catch (UnsupportedEncodingException e) {
              // This should never happen as every implementation of the java platform is required
              // to support UTF-8.
              throw new RuntimeException(e);
          } finally {
              close(instream);
          }
      }
docs: Performs a Cloudant Search and returns the result as an {@link SearchResult}
  
  @param <T>      Object type T, an instance into which the rows[].doc/group[].rows[].doc
  attribute of the Search result response should be deserialized into. Same
  goes for the rows[].fields/group[].rows[].fields attribute
  @param query    the Lucene query to be passed to the Search index
  @param classOfT The class of type T.
  @return The Search result entries