### Question:
SolrClient extends SearchClient { @Override public FacetResult facet(QueryRequest query) throws SearchClientException, IOException { String url = generateRequestURL(query); byte[] bytes = get(url); JsonParser parser = new JsonParser(); JsonElement root = null; try (Reader reader = new BufferedReader( new InputStreamReader( new ByteArrayInputStream(bytes), StandardCharsets.UTF_8))) { root = parser.parse(reader); } JsonObject response = (JsonObject) ((JsonObject) root).get("response"); long totalDocs = response.get("numFound").getAsLong(); JsonObject facetCounts = (JsonObject) ((JsonObject) root).get("facet_counts"); JsonObject facetFields = (JsonObject) facetCounts.get("facet_fields"); String facetField = query.getFacetField(); JsonArray arr = (JsonArray) facetFields.get(facetField); Map<String, Long> counts = new HashMap<>(); for (int i = 0; i < arr.size() - 1; i += 2) { JsonElement valueElement = arr.get(i); String value = null; if (valueElement.isJsonNull()) { value = "null"; } else { value = valueElement.getAsString(); } long count = arr.get(i + 1).getAsLong(); counts.put(value, count); } return new FacetResult(totalDocs, counts); } protected  SolrClient(String url); @Override SearchResultSet search(QueryRequest query); @Override FacetResult facet(QueryRequest query); @Override void addDocuments(List<StoredDocument> buildDocuments); @Override List<StoredDocument> getDocs(String idField, Set<String> ids,
                                        Set<String> whiteListFields,
                                        Set<String> blackListFields); @Override Set<String> getCopyFields(); @Override synchronized String getDefaultIdField(); @Override void deleteAll(); @Override IdGrabber getIdGrabber(ArrayBlockingQueue<Set<String>> ids, int batchSize,
                                  int copierThreads, Collection<Query> filterQueries); @Override Set<String> getSystemInternalFields(); @Override List<String> analyze(String field, String string); @Override List<TokenDF> getTerms(String field, String lower,
                                  int limit, int minCount);  }### Answer:
@Test public void testFacets() throws Exception { SolrClient client = new SolrClient(TMDB_URL); QueryRequest queryRequest = new QueryRequest(ALL_DOCS); queryRequest.setFacetField("genres_facet"); queryRequest.setFacetLimit(20000); FacetResult result = client.facet(queryRequest); Map<String, Long> counts = result.getFacetCounts(); assertEquals(21, counts.size()); assertEquals(13582, counts.get("drama")); assertEquals(243, counts.get("tv movie")); queryRequest = new QueryRequest(ALL_DOCS); queryRequest.setFacetField("production_companies_facet"); queryRequest.setFacetLimit(20000); result = client.facet(queryRequest); counts = result.getFacetCounts(); assertEquals(15905, counts.size()); assertEquals(1, counts.get("haile gerima")); assertEquals(90, counts.get("dreamworks skg")); EDisMaxQuery q = new EDisMaxQuery("red"); q.getQF().add(new WeightableField("title")); testRed(q); DisMaxQuery disMaxQuery = new DisMaxQuery("red"); disMaxQuery.getQF().add(new WeightableField("title")); testRed(disMaxQuery); TermQuery tq = new TermQuery("title", "red"); testRed(tq); TermsQuery tsq = new TermsQuery("title", Collections.singletonList("red")); testRed(tsq); LuceneQuery luceneQuery = new LuceneQuery("", "title:red"); testRed(luceneQuery); luceneQuery = new LuceneQuery("title", "red"); testRed(luceneQuery); }