@Test public void extractFacetCounts_FIELD_FACET() { Map<String, Integer> facetResultsCount = Maps.newHashMap(); facetResultsCount.put("key1", 1); facetResultsCount.put("key2", 5); QueryResponse response = createQueryResponseWithFieldFacet("judgmentDate", facetResultsCount); List<FacetCount> facetCounts = xFieldFacetExtractor.extractFacetCounts(response, XField.JUDGMENT_DATE); assertEquals(2, facetCounts.size()); assertEquals("key1", facetCounts.get(0).getValue()); assertEquals(1, facetCounts.get(0).getCount()); assertEquals("key2", facetCounts.get(1).getValue()); assertEquals(5, facetCounts.get(1).getCount()); }
public List<FacetCount> extractFacetCounts(QueryResponse response, XField xField) { Preconditions.checkNotNull(response); Preconditions.checkNotNull(xField); String fieldName = xFieldNameMapper.mapXField(xField); RangeFacet<?, ?> facetRange = extractRangeFacet(response, fieldName); FacetField facetField = extractFieldFacet(response, fieldName); if (facetRange != null) { return convertRangeFacetCounts(facetRange); } if (facetField != null) { return convertFieldFacetCounts(facetField); } throw new RuntimeException("No field or range facet for field name " + fieldName + " in solr query response"); }
XFieldFacetExtractor { public List<FacetCount> extractFacetCounts(QueryResponse response, XField xField) { Preconditions.checkNotNull(response); Preconditions.checkNotNull(xField); String fieldName = xFieldNameMapper.mapXField(xField); RangeFacet<?, ?> facetRange = extractRangeFacet(response, fieldName); FacetField facetField = extractFieldFacet(response, fieldName); if (facetRange != null) { return convertRangeFacetCounts(facetRange); } if (facetField != null) { return convertFieldFacetCounts(facetField); } throw new RuntimeException("No field or range facet for field name " + fieldName + " in solr query response"); } }
XFieldFacetExtractor { public List<FacetCount> extractFacetCounts(QueryResponse response, XField xField) { Preconditions.checkNotNull(response); Preconditions.checkNotNull(xField); String fieldName = xFieldNameMapper.mapXField(xField); RangeFacet<?, ?> facetRange = extractRangeFacet(response, fieldName); FacetField facetField = extractFieldFacet(response, fieldName); if (facetRange != null) { return convertRangeFacetCounts(facetRange); } if (facetField != null) { return convertFieldFacetCounts(facetField); } throw new RuntimeException("No field or range facet for field name " + fieldName + " in solr query response"); }  }
XFieldFacetExtractor { public List<FacetCount> extractFacetCounts(QueryResponse response, XField xField) { Preconditions.checkNotNull(response); Preconditions.checkNotNull(xField); String fieldName = xFieldNameMapper.mapXField(xField); RangeFacet<?, ?> facetRange = extractRangeFacet(response, fieldName); FacetField facetField = extractFieldFacet(response, fieldName); if (facetRange != null) { return convertRangeFacetCounts(facetRange); } if (facetField != null) { return convertFieldFacetCounts(facetField); } throw new RuntimeException("No field or range facet for field name " + fieldName + " in solr query response"); }  List<FacetCount> extractFacetCounts(QueryResponse response, XField xField); @Resource void setxFieldNameMapper(XFieldNameMapper xFieldNameMapper); }
XFieldFacetExtractor { public List<FacetCount> extractFacetCounts(QueryResponse response, XField xField) { Preconditions.checkNotNull(response); Preconditions.checkNotNull(xField); String fieldName = xFieldNameMapper.mapXField(xField); RangeFacet<?, ?> facetRange = extractRangeFacet(response, fieldName); FacetField facetField = extractFieldFacet(response, fieldName); if (facetRange != null) { return convertRangeFacetCounts(facetRange); } if (facetField != null) { return convertFieldFacetCounts(facetField); } throw new RuntimeException("No field or range facet for field name " + fieldName + " in solr query response"); }  List<FacetCount> extractFacetCounts(QueryResponse response, XField xField); @Resource void setxFieldNameMapper(XFieldNameMapper xFieldNameMapper);  }