@Override public FacetsCollector newCollector() throws IOException { return new FacetsCollector(); }
/** Returns the original matching documents. */ public List<MatchingDocs> getOriginalMatchingDocs() { return super.getMatchingDocs(); }
/** Utility method, to search and also collect all hits * into the provided {@link Collector}. */ public static TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, int n, Collector fc) throws IOException { return doSearch(searcher, after, q, n, null, false, false, fc); }
@Override public final FacetsCollector getFacetsCollector() { if (facetsCollector != null) // cache return facetsCollector; if (queryExecution.queryDef.facets == null || queryExecution.queryDef.facets.isEmpty()) return null; if (queryCollectorsList == null || queryCollectorsList.isEmpty()) return EMPTY_FACETS_COLLECTOR; facetsCollector = new FacetsCollector(); final List<FacetsCollector.MatchingDocs> matchingDocs = facetsCollector.getMatchingDocs(); for (QueryCollectorsClassic queryCollectors : queryCollectorsList) if (queryCollectors.facetsCollector != null) matchingDocs.addAll(queryCollectors.facetsCollector.getMatchingDocs()); return facetsCollector; }
/** * Aggreggates float facet values from the provided * {@link DoubleValuesSource}, and pulls ordinals from the * provided {@link OrdinalsReader}. */ public TaxonomyFacetSumValueSource(OrdinalsReader ordinalsReader, TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, DoubleValuesSource vs) throws IOException { super(ordinalsReader.getIndexFieldName(), taxoReader, config); this.ordinalsReader = ordinalsReader; sumValues(fc.getMatchingDocs(), fc.getKeepScores(), vs); }
/** User runs a query and counts facets. */ public FacetResult search() throws IOException { // Aggregates the facet counts FacetsCollector fc = new FacetsCollector(); // MatchAllDocsQuery is for "browsing" (counts facets // for all non-deleted docs in the index); normally // you'd use a "normal" query: FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc); Facets facets = new LongRangeFacetCounts("timestamp", fc, PAST_HOUR, PAST_SIX_HOURS, PAST_DAY); return facets.getTopChildren(10, "timestamp"); }
/** User runs a query and counts facets. */ private List<FacetResult> search() throws IOException { DirectoryReader indexReader = DirectoryReader.open(indexDir); IndexSearcher searcher = new IndexSearcher(indexReader); SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader); // Aggregatses the facet counts FacetsCollector fc = new FacetsCollector(); // MatchAllDocsQuery is for "browsing" (counts facets // for all non-deleted docs in the index); normally // you'd use a "normal" query: FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc); // Retrieve results Facets facets = new SortedSetDocValuesFacetCounts(state, fc); List<FacetResult> results = new ArrayList<>(); results.add(facets.getTopChildren(10, "Author")); results.add(facets.getTopChildren(10, "Publish Year")); indexReader.close(); return results; }
/** Aggreggates float facet values from the provided * {@link ValueSource}, and pulls ordinals from the * provided {@link OrdinalsReader}. */ public TaxonomyFacetSumValueSource(OrdinalsReader ordinalsReader, TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, ValueSource valueSource) throws IOException { super(ordinalsReader.getIndexFieldName(), taxoReader, config); this.ordinalsReader = ordinalsReader; sumValues(fc.getMatchingDocs(), fc.getKeepScores(), valueSource); }
/** User drills down on 'Publish Year/2010'. */ private FacetResult drillDown() throws IOException { DirectoryReader indexReader = DirectoryReader.open(indexDir); IndexSearcher searcher = new IndexSearcher(indexReader); SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader); // Now user drills down on Publish Year/2010: DrillDownQuery q = new DrillDownQuery(config); q.add("Publish Year", "2010"); FacetsCollector fc = new FacetsCollector(); FacetsCollector.search(searcher, q, 10, fc); // Retrieve results Facets facets = new SortedSetDocValuesFacetCounts(state, fc); FacetResult result = facets.getTopChildren(10, "Author"); indexReader.close(); return result; }
private FacetsCollector buildFacetsCollector(final LinkedHashMap<String, FacetDefinition> facets) { if (facets == null || facets.isEmpty()) return null; for (FacetDefinition facet : facets.values()) if (facet.queries == null || facet.queries.isEmpty()) return add(new FacetsCollector()); return null; }
/** Returns the original matching documents. */ public List<MatchingDocs> getOriginalMatchingDocs() { return super.getMatchingDocs(); }
/** Utility method, to search and also collect all hits * into the provided {@link Collector}. */ public static TopDocs search(IndexSearcher searcher, Query q, int n, Collector fc) throws IOException { return doSearch(searcher, null, q, n, null, false, false, fc); }
/** User runs a query and counts facets. */ private List<FacetResult> facetsWithSearch() throws IOException { DirectoryReader indexReader = DirectoryReader.open(indexDir); IndexSearcher searcher = new IndexSearcher(indexReader); TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir); FacetsCollector fc = new FacetsCollector(); // MatchAllDocsQuery is for "browsing" (counts facets // for all non-deleted docs in the index); normally // you'd use a "normal" query: FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc); // Retrieve results List<FacetResult> results = new ArrayList<>(); // Count both "Publish Date" and "Author" dimensions Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc); results.add(facets.getTopChildren(10, "Author")); results.add(facets.getTopChildren(10, "Publish Date")); indexReader.close(); taxoReader.close(); return results; }
private Collector optionallyEnableFacetingCollector(Collector collector) { if ( facetingRequestsAndMetadata == null || facetingRequestsAndMetadata.isEmpty() ) { return collector; } facetsCollector = new FacetsCollector(); return MultiCollector.wrap( facetsCollector, collector ); }
/** Create {@code RangeFacetCounts}, using the provided * {@link ValueSource}, and using the provided Query as * a fastmatch: only documents passing the filter are * checked for the matching ranges. The filter must be * random access (implement {@link DocIdSet#bits}). */ public DoubleRangeFacetCounts(String field, ValueSource valueSource, FacetsCollector hits, Query fastMatchQuery, DoubleRange... ranges) throws IOException { super(field, ranges, fastMatchQuery); count(valueSource, hits.getMatchingDocs()); }
/** Utility method, to search and also collect all hits * into the provided {@link Collector}. */ public static TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, int n, Collector fc) throws IOException { return doSearch(searcher, after, q, n, null, false, false, fc); }
/** User runs a query and counts facets. */ private List<FacetResult> search() throws IOException { DirectoryReader indexReader = DirectoryReader.open(indexDir); IndexSearcher searcher = new IndexSearcher(indexReader); TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir); FacetsCollector fc = new FacetsCollector(); // MatchAllDocsQuery is for "browsing" (counts facets // for all non-deleted docs in the index); normally // you'd use a "normal" query: FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc); // Retrieve results List<FacetResult> results = new ArrayList<>(); // Count both "Publish Date" and "Author" dimensions Facets author = new FastTaxonomyFacetCounts("author", taxoReader, config, fc); results.add(author.getTopChildren(10, "Author")); Facets pubDate = new FastTaxonomyFacetCounts("pubdate", taxoReader, config, fc); results.add(pubDate.getTopChildren(10, "Publish Date")); indexReader.close(); taxoReader.close(); return results; }
private Collector optionallyEnableFacetingCollector(Collector collector) { if ( facetingRequestsAndMetadata == null || facetingRequestsAndMetadata.isEmpty() ) { return collector; } facetsCollector = new FacetsCollector(); return MultiCollector.wrap( facetsCollector, collector ); }
public ReducedFacetsCollector(final Collection<FacetsCollector> facetsCollectors) { final List<MatchingDocs> matchingDocs = this.getMatchingDocs(); facetsCollectors.forEach(facetsCollector -> matchingDocs.addAll(facetsCollector.getMatchingDocs())); } }
/** Utility method, to search and also collect all hits * into the provided {@link Collector}. */ public static TopDocs search(IndexSearcher searcher, Query q, int n, Collector fc) throws IOException { return doSearch(searcher, null, q, n, null, false, false, fc); }