/** * Returns a <code>NamedList</code> with each entry having the "key" of the interval as name and * the count of docs in that interval as value. All intervals added in the request are included in * the returned <code>NamedList</code> (included those with 0 count), and it's required that the * order of the intervals is deterministic and equals in all shards of a distributed request, * otherwise the collation of results will fail. */ public NamedList<Object> getFacetIntervalCounts() throws IOException, SyntaxError { NamedList<Object> res = new SimpleOrderedMap<Object>(); String[] fields = global.getParams(FacetParams.FACET_INTERVAL); if (fields == null || fields.length == 0) return res; for (String field : fields) { final ParsedParams parsed = parseParams(FacetParams.FACET_INTERVAL, field); String[] intervalStrs = parsed.required.getFieldParams(parsed.facetValue, FacetParams.FACET_INTERVAL_SET); SchemaField schemaField = searcher.getCore().getLatestSchema().getField(parsed.facetValue); if (parsed.params.getBool(GroupParams.GROUP_FACET, false)) { throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Interval Faceting can't be used with " + GroupParams.GROUP_FACET); } SimpleOrderedMap<Integer> fieldResults = new SimpleOrderedMap<Integer>(); res.add(parsed.key, fieldResults); IntervalFacets intervalFacets = new IntervalFacets(schemaField, searcher, parsed.docs, intervalStrs, parsed.params); for (FacetInterval interval : intervalFacets) { fieldResults.add(interval.getKey(), interval.getCount()); } } return res; }
boolean waitForNewSearcher(int timeout) { long timeoutTime = System.currentTimeMillis() + timeout; while (System.currentTimeMillis() < timeoutTime) { if (triggered) { // check if the new searcher has been registered yet RefCounted<SolrIndexSearcher> registeredSearcherH = newSearcher.getCore().getSearcher(); SolrIndexSearcher registeredSearcher = registeredSearcherH.get(); registeredSearcherH.decref(); if (registeredSearcher == newSearcher) return true; // log.info("TEST: waiting for searcher " + newSearcher + " to be registered. current=" + // registeredSearcher); } try { Thread.sleep(250); } catch (InterruptedException e) { } } return false; }