protected void setMaxFacets ( SolrQuery squery, Integer maxFacets ) { // set max results // WARNING in solr 3.6 // * an *NumberFormatException* occurs if _rows_ > 2147483647 // * an *ArrayIndexOutOfBoundsException* occurs if _rows_ + _start_ > 2147483647; e.g. _rows_ = 2147483640 and _start_ = 8 // we need to substract to avoid this exception if ( maxFacets != null ) { squery.setFacetLimit ( maxFacets ) ; } else { if ( squery.getStart ( ) == null ) { squery.setStart ( 0 ) ; } squery.setFacetLimit ( Integer.MAX_VALUE - squery.getStart ( ) ) ; } }
query.setFacetLimit(Integer.parseInt(fields.get(IndexingConstants.FACET_LIMIT))); fields.remove(IndexingConstants.FACET_LIMIT); } else { query.setFacetLimit(IndexingConstants.FACET_LIMIT_DEFAULT);
private void addFacetParameters(SolrQuery query) { query.setFacet(true); query.addFacetField(facetFieldExtractor.getRandomFacetField()); query.setFacetMinCount(facetMinCount); query.setFacetLimit(facetLimit); if(facetMethod != null && !"".equals(facetMethod)) { query.add("facet.method", facetMethod); } }
public ArrayList<ServerDetail> getList(SolrServer realTimeThoth) throws SolrServerException { ArrayList<ServerDetail> serverDetails = new ArrayList<ServerDetail>(); // Using HierarchicalFaceting to fetch server details .http://wiki.apache.org/solr/HierarchicalFaceting QueryResponse qr = realTimeThoth.query(new SolrQuery("*:*").addFacetPivotField(FACET_PIVOT_FIELDS).setRows(0).setFacetLimit(FACET_LIMIT)); NamedList<List<PivotField>> pivots = qr.getFacetPivot(); System.out.println("Found " + pivots.get(FACET_PIVOT_FIELDS).size()+" servers to monitor. Fetching information for these servers. Please wait"); for (PivotField pivot: pivots.get(FACET_PIVOT_FIELDS)){ String hostname = (String) pivot.getValue(); for (PivotField pf: pivot.getPivot()){ String coreName = (String) pf.getValue(); ServerDetail detail = fetchServerDetails(hostname,coreName, realTimeThoth); if (detail != null) serverDetails.add(detail); } } return serverDetails; }
public Multimap<String,InteractorIdCount> searchInteractors(SolrQuery originalQuery, String[] interactorTypeMis) throws IntactSolrException { SolrQuery query = originalQuery.getCopy(); query.setRows(0); query.setFacet(true); query.setFacetMinCount(1); query.setFacetLimit(Integer.MAX_VALUE); query.setFacetSort(FacetParams.FACET_SORT_COUNT); Multimap<String,InteractorIdCount> interactors = HashMultimap.create(); Map<String,String> fieldNameToTypeMap = new HashMap<String,String>(interactorTypeMis.length); for (String mi : interactorTypeMis) { final String fieldName = createFieldName(mi); query.addFacetField(fieldName); fieldNameToTypeMap.put(fieldName, mi); } QueryResponse queryResponse = executeQuery(query); for (Map.Entry<String,String> entry : fieldNameToTypeMap.entrySet()) { FacetField ff = queryResponse.getFacetField(entry.getKey()); if (ff != null && ff.getValues() != null) { for (FacetField.Count c : ff.getValues()) { interactors.put(entry.getValue(), new InteractorIdCount(c.getName(), c.getCount())); } } } return interactors; }
solrQuery.setFacetLimit(max);
solrQuery.setFacetLimit(max);
public Set<String> getOntologyNames() throws SolrServerException { if (ontologyNames == null) { SolrQuery query = new SolrQuery("*:*"); query.setStart(0); query.setRows(0); // prepare faceting query.setFacet(true); query.setParam(FacetParams.FACET_FIELD, "ontology"); query.setFacetLimit(10); query.setFacetMinCount(1); query.set(FacetParams.FACET_OFFSET, 0); // order by unique id query.addSortField(OntologyFieldNames.ID, SolrQuery.ORDER.asc); QueryResponse response = search(query, null); FacetField facetField = response.getFacetField("ontology"); if (facetField.getValues() == null) { return Collections.EMPTY_SET; } ontologyNames = new HashSet<String>( facetField.getValues().size() ); for (FacetField.Count c : facetField.getValues()) { ontologyNames.add(c.getName()); } } return ontologyNames; }
query.setFacetLimit(CHUNK_FACET_THRESHOLD);
query.setFacet(true); query.setFacetMinCount(criteria.getFacetMinCount()); query.setFacetLimit(criteria.getFacetLimit());
for (String facet : facets._facets) query.addFacetField(facet); query.setFacetLimit(facets.limit); query.setFacetMinCount(facets.mincount); query.setFacetMissing(facets.missing);
query.setFacetLimit(facets.limit); query.setFacetMinCount(facets.mincount); query.setFacetMissing(facets.missing);
private boolean enableFaceting(SolrQuery solrQuery, FacetQuery query) { FacetOptions facetOptions = query.getFacetOptions(); if (facetOptions == null || !facetOptions.hasFacets()) { return false; } solrQuery.setFacet(true); solrQuery.setFacetMinCount(facetOptions.getFacetMinCount()); solrQuery.setFacetLimit(facetOptions.getPageable().getPageSize()); if (facetOptions.getPageable().getPageNumber() > 0) { long offset = Math.max(0, facetOptions.getPageable().getOffset()); solrQuery.set(FacetParams.FACET_OFFSET, "" + offset); } if (FacetOptions.FacetSort.INDEX.equals(facetOptions.getFacetSort())) { solrQuery.setFacetSort(FacetParams.FACET_SORT_INDEX); } return true; }
query.setFacetLimit(search.getFacetLimit());
querySolr.setFacet(true); querySolr.setFacetMinCount(queryWithoutSelect.getFacetMinCount()); querySolr.setFacetLimit(queryWithoutSelect.getFacetLimit()); querySolr.setFacetSort(queryWithoutSelect.getFacetSort().solrValue);
solrQuery.setFacetLimit(facetLimit);
query.setFacetLimit(getFacetLimit());