@Override public String execute() { super.execute(); // replace organisation keys with real names lookupFacetTitles(DatasetSearchParameter.HOSTING_ORG, getOrgTitle); lookupFacetTitles(DatasetSearchParameter.OWNING_ORG, getOrgTitle); lookupFacetTitles(DatasetSearchParameter.TYPE, getDatasetTypeTitle); lookupFacetTitles(DatasetSearchParameter.PUBLISHING_COUNTRY, getCountryTitle); // populate counts for (DatasetSearchResult dsr : getSearchResponse().getResults()) { if (DatasetType.OCCURRENCE == dsr.getType()) { Long count = occurrenceCube.get(new ReadBuilder().at(OccurrenceCube.DATASET_KEY, dsr.getKey())); recordCounts.put(dsr.getKey(), count); } else if (DatasetType.CHECKLIST == dsr.getType()) { // Client response status 204 (Equal to no content) gets converted into NULL // See HttpErrorResponseInterceptor.java in gbif-common-ws for more information DatasetMetrics metrics = checklistMetricsService.get(dsr.getKey()); if (metrics != null) { recordCounts.put(dsr.getKey(), Long.valueOf(metrics.getUsagesCount())); } } } return SUCCESS; }
/** * Checks if the dataset search result match (highlighted text) only occurred in the full text * field. This method goes through all highlighted fields that may be highlighted: * * <pre> * <arr name="hl.fl"> * <str>dataset_title</str> * <str>keyword</str> * <str>iso_country_code</str> * <str>owning_organization_title</str> * <str>hosting_organization_title</str> * <str>description</str> * </arr> * </pre> * * If there is no highlighted text in any of these fields, it can be inferred that the match must * have occurred in the full text field. </br> If the query text was null, there can be no * matching anyways so the method just returns false. * * @param result DatasetSearchResult * @return whether a match only occurred on the full text field or not */ public static boolean isFullTextMatchOnly(DatasetSearchResult result, String query) { if (Strings.isNullOrEmpty(query)) { return false; } final String keywords = result.getKeywords() == null ? "" : TOKEN_JOINER.join(result.getKeywords()); if (isHighlightedText(result.getTitle()) || isHighlightedText(result.getDescription()) || isHighlightedText(result.getOwningOrganizationTitle()) || isHighlightedText(result.getHostingOrganizationTitle()) || isHighlightedText(keywords)) { return false; } // otherwise, it must have been a match against the full_text field return true; }