List of usage examples for org.apache.solr.client.solrj SolrQuery setQuery
public SolrQuery setQuery(String query)
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * Downloads the records for the supplied query. Used to break up the download into components * 1) 1 call for each data resource that has a download limit (supply the data resource uid as the argument dataResource) * 2) 1 call for the remaining records/*from w w w.j a v a 2 s. co m*/ * * @param downloadParams * @param downloadLimit * @param uidStats * @param fields * @param qaFields * @param resultsCount * @param dataResource The dataResource being download. This should be null if multiple data resource are being downloaded. * @return * @throws Exception */ private int downloadRecords(DownloadRequestParams downloadParams, RecordWriterError writer, Map<String, Integer> downloadLimit, ConcurrentMap<String, AtomicInteger> uidStats, String[] fields, String[] qaFields, int resultsCount, String dataResource, boolean includeSensitive, DownloadDetailsDTO dd, boolean limit, String[] analysisLayers) throws Exception { if (logger.isInfoEnabled()) { logger.info("download query: " + downloadParams.getQ()); } SolrQuery solrQuery = initSolrQuery(downloadParams, false, null); solrQuery.setRows(limit ? MAX_DOWNLOAD_SIZE : -1); queryFormatUtils.formatSearchQuery(downloadParams); solrQuery.setQuery(downloadParams.getFormattedQuery()); //Only the fields specified below will be included in the results from the SOLR Query solrQuery.setFields("row_key", "institution_uid", "collection_uid", "data_resource_uid", "data_provider_uid"); if (dd != null) { dd.resetCounts(); } //get coordinates for analysis layer intersection if (analysisLayers.length > 0) { if (!includeSensitive && dd.getSensitiveFq() != null) { for (String s : sensitiveSOLRHdr) solrQuery.addField(s); } else { for (String s : notSensitiveSOLRHdr) solrQuery.addField(s); } } int pageSize = downloadBatchSize; StringBuilder sb = new StringBuilder(downloadParams.getFields()); if (downloadParams.getExtra().length() > 0) { sb.append(",").append(downloadParams.getExtra()); } List<SolrQuery> queries = new ArrayList<SolrQuery>(); queries.add(solrQuery); //split into sensitive and non-sensitive queries when // - not including all sensitive values // - there is a sensitive fq List<SolrQuery> sensitiveQ = new ArrayList<SolrQuery>(); if (!includeSensitive && dd.getSensitiveFq() != null) { sensitiveQ = splitQueries(queries, dd.getSensitiveFq(), null, null); } final String[] sensitiveFields; final String[] notSensitiveFields; if (!includeSensitive && dd.getSensitiveFq() != null) { //lookup for fields from sensitive queries sensitiveFields = org.apache.commons.lang3.ArrayUtils.addAll(fields, sensitiveCassandraHdr); //use general fields when sensitive data is not permitted notSensitiveFields = org.apache.commons.lang3.ArrayUtils.addAll(fields, notSensitiveCassandraHdr); } else { sensitiveFields = new String[0]; notSensitiveFields = fields; } for (SolrQuery q : queries) { int startIndex = 0; String[] fq = downloadParams.getFormattedFq(); if (q.getFilterQueries() != null && q.getFilterQueries().length > 0) { if (fq == null) { fq = new String[0]; } fq = org.apache.commons.lang3.ArrayUtils.addAll(fq, q.getFilterQueries()); } QueryResponse qr = runSolrQuery(q, fq, pageSize, startIndex, "_docid_", "asc"); List<String> uuids = new ArrayList<String>(); List<String[]> intersectionAll = intersectResults(dd.getRequestParams().getLayersServiceUrl(), analysisLayers, qr.getResults()); while (qr.getResults().size() > 0 && (!limit || resultsCount < MAX_DOWNLOAD_SIZE) && shouldDownload(dataResource, downloadLimit, false)) { if (logger.isDebugEnabled()) { logger.debug("Start index: " + startIndex); } Map<String, String[]> dataToInsert = new HashMap<String, String[]>(); //cycle through the results adding them to the list that will be sent to cassandra int row = 0; for (SolrDocument sd : qr.getResults()) { if (sd.getFieldValue("data_resource_uid") != null) { String druid = sd.getFieldValue("data_resource_uid").toString(); if (shouldDownload(druid, downloadLimit, true) && (!limit || resultsCount < MAX_DOWNLOAD_SIZE)) { resultsCount++; uuids.add(sd.getFieldValue("row_key").toString()); //include analysis layer intersections if (intersectionAll.size() > row + 1) dataToInsert.put(sd.getFieldValue("row_key").toString(), (String[]) ArrayUtils.subarray(intersectionAll.get(row + 1), 2, intersectionAll.get(row + 1).length)); //increment the counters.... incrementCount(uidStats, sd.getFieldValue("institution_uid")); incrementCount(uidStats, sd.getFieldValue("collection_uid")); incrementCount(uidStats, sd.getFieldValue("data_provider_uid")); incrementCount(uidStats, druid); } } row++; } String[] newMiscFields; if (sensitiveQ.contains(q)) { newMiscFields = au.org.ala.biocache.Store.writeToWriter(writer, uuids.toArray(new String[] {}), sensitiveFields, qaFields, true, (dd.getRequestParams() != null ? dd.getRequestParams().getIncludeMisc() : false), dd.getMiscFields(), dataToInsert); } else { newMiscFields = au.org.ala.biocache.Store.writeToWriter(writer, uuids.toArray(new String[] {}), notSensitiveFields, qaFields, includeSensitive, (dd.getRequestParams() != null ? dd.getRequestParams().getIncludeMisc() : false), dd.getMiscFields(), dataToInsert); } //test for errors if (writer.hasError()) { throw RecordWriterException.newRecordWriterException(dd, downloadParams, false, writer); } dd.setMiscFields(newMiscFields); startIndex += pageSize; uuids.clear(); dd.updateCounts(qr.getResults().size()); if (!limit || resultsCount < MAX_DOWNLOAD_SIZE) { //we have already set the Filter query the first time the query was constructed rerun with he same params but different startIndex qr = runSolrQuery(q, null, pageSize, startIndex, "_docid_", "asc"); } } } return resultsCount; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
private List<OccurrencePoint> getPoints(SpatialSearchRequestParams searchParams, PointType pointType, int max) throws Exception { List<OccurrencePoint> points = new ArrayList<OccurrencePoint>(); // new OccurrencePoint(PointType.POINT); queryFormatUtils.formatSearchQuery(searchParams); if (logger.isInfoEnabled()) { logger.info("search query: " + searchParams.getFormattedQuery()); }//from w w w . j av a 2 s. c o m SolrQuery solrQuery = new SolrQuery(); solrQuery.setQueryType("standard"); solrQuery.setQuery(searchParams.getFormattedQuery()); solrQuery.setRows(0); solrQuery.setFacet(true); solrQuery.addFacetField(pointType.getLabel()); solrQuery.setFacetMinCount(1); solrQuery.setFacetLimit(max); // unlimited = -1 QueryResponse qr = runSolrQuery(solrQuery, searchParams.getFormattedFq(), 1, 0, "score", "asc"); List<FacetField> facets = qr.getFacetFields(); if (facets != null) { for (FacetField facet : facets) { List<FacetField.Count> facetEntries = facet.getValues(); if (facet.getName().contains(pointType.getLabel()) && (facetEntries != null) && (facetEntries.size() > 0)) { for (FacetField.Count fcount : facetEntries) { if (StringUtils.isNotEmpty(fcount.getName()) && fcount.getCount() > 0) { OccurrencePoint point = new OccurrencePoint(pointType); point.setCount(fcount.getCount()); String[] pointsDelimited = StringUtils.split(fcount.getName(), ','); List<Float> coords = new ArrayList<Float>(); for (String coord : pointsDelimited) { try { Float decimalCoord = Float.parseFloat(coord); coords.add(decimalCoord); } catch (NumberFormatException numberFormatException) { logger.warn("Error parsing Float for Lat/Long: " + numberFormatException.getMessage(), numberFormatException); } } if (!coords.isEmpty()) { Collections.reverse(coords); // must be long, lat order point.setCoordinates(coords); points.add(point); } } } } } } return points; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * @see au.org.ala.biocache.dao.SearchDAO#getFacetPointsShort(au.org.ala.biocache.dto.SpatialSearchRequestParams, String) *//*from ww w. j a va 2 s .c o m*/ @Override public FacetField getFacetPointsShort(SpatialSearchRequestParams searchParams, String pointType) throws Exception { queryFormatUtils.formatSearchQuery(searchParams); if (logger.isInfoEnabled()) { logger.info("search query: " + searchParams.getFormattedQuery()); } SolrQuery solrQuery = new SolrQuery(); solrQuery.setRequestHandler("standard"); solrQuery.setQuery(searchParams.getFormattedQuery()); solrQuery.setRows(0); solrQuery.setFacet(true); solrQuery.addFacetField(pointType); solrQuery.setFacetMinCount(1); solrQuery.setFacetLimit(searchParams.getFlimit());//MAX_DOWNLOAD_SIZE); // unlimited = -1 QueryResponse qr = runSolrQuery(solrQuery, searchParams.getFormattedFq(), 0, 0, "_docid_", "asc"); List<FacetField> facets = qr.getFacetFields(); //return first facet, there should only be 1 if (facets != null && facets.size() > 0) { return facets.get(0); } return null; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * @see au.org.ala.biocache.dao.SearchDAO#getOccurrences(au.org.ala.biocache.dto.SpatialSearchRequestParams, au.org.ala.biocache.dto.PointType, String) */// www . j a v a2 s . c o m @Override public List<OccurrencePoint> getOccurrences(SpatialSearchRequestParams searchParams, PointType pointType, String colourBy) throws Exception { List<OccurrencePoint> points = new ArrayList<OccurrencePoint>(); searchParams.setPageSize(100); String queryString = ""; queryFormatUtils.formatSearchQuery(searchParams); queryString = searchParams.getFormattedQuery(); if (logger.isInfoEnabled()) { logger.info("search query: " + queryString); } SolrQuery solrQuery = new SolrQuery(); solrQuery.setQueryType("standard"); solrQuery.setQuery(queryString); solrQuery.setRows(0); solrQuery.setFacet(true); solrQuery.addFacetField(pointType.getLabel()); solrQuery.setFacetMinCount(1); solrQuery.setFacetLimit(MAX_DOWNLOAD_SIZE); // unlimited = -1 QueryResponse qr = runSolrQuery(solrQuery, searchParams); SearchResultDTO searchResults = processSolrResponse(searchParams, qr, solrQuery, OccurrenceIndex.class); List<OccurrenceIndex> ocs = searchResults.getOccurrences(); if (!ocs.isEmpty() && ocs.size() > 0) { for (OccurrenceIndex oc : ocs) { List<Float> coords = new ArrayList<Float>(); coords.add(oc.getDecimalLongitude().floatValue()); coords.add(oc.getDecimalLatitude().floatValue()); OccurrencePoint point = new OccurrencePoint(); point.setCoordinates(coords); point.setOccurrenceUid(oc.getUuid()); points.add(point); } } return points; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * http://ala-biocache1.vm.csiro.au:8080/solr/select?q=*:*&rows=0&facet=true&facet.field=data_provider_id&facet.field=data_provider&facet.sort=data_provider_id * * @see au.org.ala.biocache.dao.SearchDAO#getDataProviderCounts() *//* www.j a va2s. com*/ //IS THIS BEING USED BY ANYTHING?? @Override public List<DataProviderCountDTO> getDataProviderCounts() throws Exception { List<DataProviderCountDTO> dpDTOs = new ArrayList<DataProviderCountDTO>(); // new OccurrencePoint(PointType.POINT); SolrQuery solrQuery = new SolrQuery(); solrQuery.setQueryType("standard"); solrQuery.setQuery("*:*"); solrQuery.setRows(0); solrQuery.setFacet(true); solrQuery.addFacetField("data_provider_uid"); solrQuery.addFacetField("data_provider"); solrQuery.setFacetMinCount(1); QueryResponse qr = runSolrQuery(solrQuery, null, 1, 0, "data_provider", "asc"); List<FacetField> facets = qr.getFacetFields(); if (facets != null && facets.size() == 2) { FacetField dataProviderIdFacet = facets.get(0); FacetField dataProviderNameFacet = facets.get(1); List<FacetField.Count> dpIdEntries = dataProviderIdFacet.getValues(); List<FacetField.Count> dpNameEntries = dataProviderNameFacet.getValues(); if (dpIdEntries != null) { for (int i = 0; i < dpIdEntries.size(); i++) { FacetField.Count dpIdEntry = dpIdEntries.get(i); FacetField.Count dpNameEntry = dpNameEntries.get(i); String dataProviderId = dpIdEntry.getName(); String dataProviderName = dpNameEntry.getName(); long count = dpIdEntry.getCount(); if (count > 0) { DataProviderCountDTO dto = new DataProviderCountDTO(dataProviderId, dataProviderName, count); dpDTOs.add(dto); } } } } if (logger.isInfoEnabled()) { logger.info("Find data providers = " + dpDTOs.size()); } return dpDTOs; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * @see au.org.ala.biocache.dao.SearchDAO#findRecordByStateFor(java.lang.String) * IS THIS BEGIN USED OR NECESSARY/*from w w w. j a v a 2s . c o m*/ */ @Override public List<FieldResultDTO> findRecordByStateFor(String query) throws Exception { List<FieldResultDTO> fDTOs = new ArrayList<FieldResultDTO>(); // new OccurrencePoint(PointType.POINT); SolrQuery solrQuery = new SolrQuery(); solrQuery.setQueryType("standard"); solrQuery.setQuery(query); solrQuery.setRows(0); solrQuery.setFacet(true); solrQuery.addFacetField("state"); solrQuery.setFacetMinCount(1); QueryResponse qr = runSolrQuery(solrQuery, null, 1, 0, "data_provider", "asc"); List<FacetField> facets = qr.getFacetFields(); FacetField ff = qr.getFacetField("state"); if (ff != null) { for (Count count : ff.getValues()) { //only start adding counts when we hit a decade with some results. if (count.getCount() > 0) { FieldResultDTO f = new FieldResultDTO(count.getName(), count.getCount()); fDTOs.add(f); } } } return fDTOs; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * Calculates the breakdown of the supplied query based on the supplied params *//*from www.j a v a 2 s . c o m*/ public TaxaRankCountDTO calculateBreakdown(BreakdownRequestParams queryParams) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Attempting to find the counts for " + queryParams); } TaxaRankCountDTO trDTO = null; SolrQuery solrQuery = new SolrQuery(); solrQuery.setQueryType("standard"); queryFormatUtils.formatSearchQuery(queryParams); solrQuery.setQuery(queryParams.getFormattedQuery()); queryParams.setPageSize(0); solrQuery.setFacet(true); solrQuery.setFacetMinCount(1); solrQuery.setFacetSort("count"); solrQuery.setFacetLimit(-1); //add the rank:name as a fq if necessary if (StringUtils.isNotEmpty(queryParams.getName()) && StringUtils.isNotEmpty(queryParams.getRank())) { queryParams.setFormattedFq((String[]) ArrayUtils.addAll(queryParams.getFormattedFq(), new String[] { queryParams.getRank() + ":" + queryParams.getName() })); } //add the ranks as facets if (queryParams.getLevel() == null) { List<String> ranks = queryParams.getRank() != null ? searchUtils.getNextRanks(queryParams.getRank(), queryParams.getName() == null) : searchUtils.getRanks(); for (String r : ranks) { solrQuery.addFacetField(r); } } else { //the user has supplied the "exact" level at which to perform the breakdown solrQuery.addFacetField(queryParams.getLevel()); } QueryResponse qr = runSolrQuery(solrQuery, queryParams); if (queryParams.getMax() != null && queryParams.getMax() > 0) { //need to get the return level that the number of facets are <=max ranks need to be processed in reverse order until max is satisfied if (qr.getResults().getNumFound() > 0) { List<FacetField> ffs = qr.getFacetFields(); //reverse the facets so that they are returned in rank reverse order species, genus, family etc Collections.reverse(ffs); for (FacetField ff : ffs) { //logger.debug("Handling " + ff.getName()); trDTO = new TaxaRankCountDTO(ff.getName()); if (ff.getValues() != null && ff.getValues().size() <= queryParams.getMax()) { List<FieldResultDTO> fDTOs = new ArrayList<FieldResultDTO>(); for (Count count : ff.getValues()) { if (count.getCount() > 0) { FieldResultDTO f = new FieldResultDTO(count.getName(), count.getCount()); fDTOs.add(f); } } trDTO.setTaxa(fDTOs); break; } } } } else if (queryParams.getRank() != null || queryParams.getLevel() != null) { //just want to process normally the rank to facet on will start with the highest rank and then go down until one exists for if (qr.getResults().getNumFound() > 0) { List<FacetField> ffs = qr.getFacetFields(); for (FacetField ff : ffs) { trDTO = new TaxaRankCountDTO(ff.getName()); if (ff != null && ff.getValues() != null) { List<Count> counts = ff.getValues(); if (counts.size() > 0) { List<FieldResultDTO> fDTOs = new ArrayList<FieldResultDTO>(); for (Count count : counts) { if (count.getCount() > 0) { FieldResultDTO f = new FieldResultDTO(count.getName(), count.getCount()); fDTOs.add(f); } } trDTO.setTaxa(fDTOs); break; } } } } } return trDTO; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * @see au.org.ala.biocache.dao.SearchDAO#findTaxonCountForUid(au.org.ala.biocache.dto.BreakdownRequestParams, String) * @deprecated use {@link #calculateBreakdown(BreakdownRequestParams)} instead *///from w w w. j ava2 s . c o m @Deprecated public TaxaRankCountDTO findTaxonCountForUid(BreakdownRequestParams breakdownParams, String query) throws Exception { TaxaRankCountDTO trDTO = null; List<String> ranks = breakdownParams.getLevel() == null ? searchUtils.getNextRanks(breakdownParams.getRank(), breakdownParams.getName() == null) : new ArrayList<String>(); if (breakdownParams.getLevel() != null) ranks.add(breakdownParams.getLevel()); if (ranks != null && ranks.size() > 0) { SolrQuery solrQuery = new SolrQuery(); solrQuery.setQueryType("standard"); solrQuery.setQuery(query); solrQuery.setRows(0); solrQuery.setFacet(true); solrQuery.setFacetMinCount(1); solrQuery.setFacetSort("count"); solrQuery.setFacetLimit(-1); //we want all facets for (String r : ranks) { solrQuery.addFacetField(r); } QueryResponse qr = runSolrQuery(solrQuery, queryFormatUtils.getQueryContextAsArray(breakdownParams.getQc()), 1, 0, breakdownParams.getRank(), "asc"); if (qr.getResults().size() > 0) { for (String r : ranks) { trDTO = new TaxaRankCountDTO(r); FacetField ff = qr.getFacetField(r); if (ff != null && ff.getValues() != null) { List<Count> counts = ff.getValues(); if (counts.size() > 0) { List<FieldResultDTO> fDTOs = new ArrayList<FieldResultDTO>(); for (Count count : counts) { FieldResultDTO f = new FieldResultDTO(count.getName(), count.getCount()); fDTOs.add(f); } trDTO.setTaxa(fDTOs); break; } } } } } return trDTO; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * Get a distinct list of species and their counts using a facet search * * @param queryString/*w w w .j a v a 2 s . co m*/ * @param pageSize * @param sortField * @param sortDirection * @return * @throws SolrServerException */ protected List<TaxaCountDTO> getSpeciesCounts(String queryString, List<String> filterQueries, List<String> facetFields, Integer pageSize, Integer startIndex, String sortField, String sortDirection) throws SolrServerException { List<TaxaCountDTO> speciesCounts = new ArrayList<TaxaCountDTO>(); SolrQuery solrQuery = new SolrQuery(); solrQuery.setQueryType("standard"); solrQuery.setQuery(queryString); if (filterQueries != null && filterQueries.size() > 0) { //solrQuery.addFilterQuery("(" + StringUtils.join(filterQueries, " OR ") + ")"); for (String fq : filterQueries) { solrQuery.addFilterQuery(fq); } } solrQuery.setRows(0); solrQuery.setFacet(true); solrQuery.setFacetSort(sortField); for (String facet : facetFields) { solrQuery.addFacetField(facet); if (logger.isDebugEnabled()) { logger.debug("adding facetField: " + facet); } } //set the facet starting point based on the paging information solrQuery.setFacetMinCount(1); solrQuery.setFacetLimit(pageSize); // unlimited = -1 | pageSize solrQuery.add("facet.offset", Integer.toString(startIndex)); if (logger.isDebugEnabled()) { logger.debug("getSpeciesCount query :" + solrQuery.getQuery()); } QueryResponse qr = runSolrQuery(solrQuery, null, 1, 0, "score", sortDirection); if (logger.isInfoEnabled()) { logger.info("SOLR query: " + solrQuery.getQuery() + "; total hits: " + qr.getResults().getNumFound()); } List<FacetField> facets = qr.getFacetFields(); java.util.regex.Pattern p = java.util.regex.Pattern.compile("\\|"); if (facets != null && facets.size() > 0) { if (logger.isDebugEnabled()) { logger.debug("Facets: " + facets.size() + "; facet #1: " + facets.get(0).getName()); } for (FacetField facet : facets) { List<FacetField.Count> facetEntries = facet.getValues(); if ((facetEntries != null) && (facetEntries.size() > 0)) { for (FacetField.Count fcount : facetEntries) { TaxaCountDTO tcDTO = null; String name = fcount.getName() != null ? fcount.getName() : ""; if (fcount.getFacetField().getName().equals(NAMES_AND_LSID)) { String[] values = p.split(name, 5); if (values.length >= 5) { if (!"||||".equals(name)) { tcDTO = new TaxaCountDTO(values[0], fcount.getCount()); tcDTO.setGuid(StringUtils.trimToNull(values[1])); tcDTO.setCommonName(values[2]); tcDTO.setKingdom(values[3]); tcDTO.setFamily(values[4]); if (StringUtils.isNotEmpty(tcDTO.getGuid())) tcDTO.setRank(searchUtils.getTaxonSearch(tcDTO.getGuid())[1].split(":")[0]); } } else { if (logger.isDebugEnabled()) { logger.debug("The values length: " + values.length + " :" + name); } tcDTO = new TaxaCountDTO(name, fcount.getCount()); } //speciesCounts.add(i, tcDTO); if (tcDTO != null && tcDTO.getCount() > 0) speciesCounts.add(tcDTO); } else if (fcount.getFacetField().getName().equals(COMMON_NAME_AND_LSID)) { String[] values = p.split(name, 6); if (values.length >= 5) { if (!"|||||".equals(name)) { tcDTO = new TaxaCountDTO(values[1], fcount.getCount()); tcDTO.setGuid(StringUtils.trimToNull(values[2])); tcDTO.setCommonName(values[0]); //cater for the bug of extra vernacular name in the result tcDTO.setKingdom(values[values.length - 2]); tcDTO.setFamily(values[values.length - 1]); if (StringUtils.isNotEmpty(tcDTO.getGuid())) tcDTO.setRank(searchUtils.getTaxonSearch(tcDTO.getGuid())[1].split(":")[0]); } } else { if (logger.isDebugEnabled()) { logger.debug("The values length: " + values.length + " :" + name); } tcDTO = new TaxaCountDTO(name, fcount.getCount()); } //speciesCounts.add(i, tcDTO); if (tcDTO != null && tcDTO.getCount() > 0) { speciesCounts.add(tcDTO); } } } } } } return speciesCounts; }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
License:Open Source License
/** * Obtains a list and facet count of the source uids for the supplied query. * * @param searchParams/*from w ww .ja v a 2 s. c o m*/ * @return * @throws Exception */ public Map<String, Integer> getSourcesForQuery(SpatialSearchRequestParams searchParams) throws Exception { Map<String, Integer> uidStats = new HashMap<String, Integer>(); SolrQuery solrQuery = new SolrQuery(); queryFormatUtils.formatSearchQuery(searchParams); if (logger.isInfoEnabled()) { logger.info("The query : " + searchParams.getFormattedQuery()); } solrQuery.setQuery(searchParams.getFormattedQuery()); solrQuery.setQueryType("standard"); solrQuery.setRows(0); solrQuery.setFacet(true); solrQuery.setFacetMinCount(1); solrQuery.addFacetField("data_provider_uid"); solrQuery.addFacetField("data_resource_uid"); solrQuery.addFacetField("collection_uid"); solrQuery.addFacetField("institution_uid"); QueryResponse qr = runSolrQuery(solrQuery, searchParams.getFormattedFq(), 1, 0, "score", "asc"); //now cycle through and get all the facets List<FacetField> facets = qr.getFacetFields(); for (FacetField facet : facets) { if (facet.getValues() != null) { for (FacetField.Count ffc : facet.getValues()) { if (ffc.getCount() > 0) { uidStats.put(ffc.getName() != null ? ffc.getName() : "", new Integer((int) ffc.getCount())); } } } } return uidStats; }