@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; }
private void renderFacetField(SearchFilterParam browseParams, DSpaceObject dso, String facetField, Table singleTable, List<String> filterQueries, DiscoverResult.FacetResult value) throws SQLException, WingException, UnsupportedEncodingException { String displayedValue = value.getDisplayedValue(); String filterQuery = value.getAsFilterQuery(); // if(field.getGap() != null){ // //We have a date get the year so we can display it // DateFormat simpleDateformat = new SimpleDateFormat("yyyy"); // displayedValue = simpleDateformat.format(SolrServiceImpl.toDate(displayedValue)); // filterQuery = ClientUtils.escapeQueryChars(value.getFacetField().getName()) + ":" + displayedValue + "*"; // } Cell cell = singleTable.addRow().addCell(); //No use in selecting the same filter twice if(filterQueries.contains(filterQuery)){ cell.addContent(displayedValue + " (" + value.getCount() + ")"); } else { //Add the basics Map<String, String> urlParams = new HashMap<String, String>(); urlParams.putAll(browseParams.getCommonBrowseParams()); String url = generateURL(contextPath + (dso == null ? "" : "/handle/" + dso.getHandle()) + "/discover", urlParams); //Add already existing filter queries url = addFilterQueriesToUrl(url); //Last add the current filter query url += "&fq=" + URLEncoder.encode(filterQuery, "UTF-8"); cell.addXref(url, displayedValue + " (" + value.getCount() + ")" ); } }
val.add(facetValue.getAsFilterQuery() + facetValue.getCount());
validity.add(facetValue.getAsFilterQuery() + facetValue.getCount());
validity.add(facetValue.getAsFilterQuery() + facetValue.getCount());
for (DiscoverResult.FacetResult facetResult : facetValues) validity.add(facetResult.getAsFilterQuery() + facetResult.getCount());