@Override public int doDistinctOffsetQuery(String column, String value, boolean isAscending) throws BrowseException { DiscoverResult resp = getSolrResponse(); List<FacetResult> facets = resp.getFacetResult(facetField); Comparator comparator = new SolrBrowseDAO.FacetValueComparator(); Collections.sort(facets, comparator); int x = Collections.binarySearch(facets, value, comparator); int ascValue = (x >= 0) ? x : -(x + 1); if (isAscending) { return ascValue; } else { return doCountQuery() - ascValue; } }
@Override public List doValueQuery() throws BrowseException { DiscoverResult resp = getSolrResponse(); List<FacetResult> facet = resp.getFacetResult(facetField); int count = doCountQuery(); int start = offset > 0 ? offset : 0; int max = limit > 0 ? limit : count; //if negative, return everything List<String[]> result = new ArrayList<>(); if (ascending) { for (int i = start; i < (start + max) && i < count; i++) { FacetResult c = facet.get(i); String freq = showFrequencies ? String.valueOf(c.getCount()) : ""; result.add(new String[] {c.getDisplayedValue(), c.getAuthorityKey(), freq}); } } else { for (int i = count - start - 1; i >= count - (start + max) && i >= 0; i--) { FacetResult c = facet.get(i); String freq = showFrequencies ? String.valueOf(c.getCount()) : ""; result.add(new String[] {c.getDisplayedValue(), c.getAuthorityKey(), freq}); } } return result; }