public List<FacetResult> getFacetResult(DiscoverySearchFilterFacet field) { List<DiscoverResult.FacetResult> facetValues = getFacetResult(field.getIndexFieldName()); //Check if we are dealing with a date, sometimes the facet values arrive as dates ! if (facetValues.size() == 0 && field.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) { facetValues = getFacetResult(field.getIndexFieldName() + ".year"); } return ListUtils.emptyIfNull(facetValues); }
@Override public int doCountQuery() throws BrowseException { DiscoverResult resp = getSolrResponse(); int count = 0; if (distinct) { List<FacetResult> facetResults = resp.getFacetResult(facetField); count = facetResults.size(); } else { // we need to cast to int to respect the BrowseDAO contract... count = (int) resp.getTotalSearchResults(); // FIXME null the response cache // the BrowseEngine send fake argument to the BrowseDAO for the // count... sResponse = null; } return count; }
@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; }
try { sResponse = searcher.search(context, query, false); List<FacetResult> commCount = sResponse.getFacetResult("location.comm"); List<FacetResult> collCount = sResponse.getFacetResult("location.coll"); for (FacetResult c : commCount) { communitiesCount.put(c.getAsFilterQuery(), (int) c.getCount());
java.util.List<DiscoverResult.FacetResult> facetValues = queryResults.getFacetResult(field.getIndexFieldName()); facetValues = queryResults.getFacetResult(field.getIndexFieldName() + ".year");