epotyom commented on code in PR #14237: URL: https://github.com/apache/lucene/pull/14237#discussion_r1960045582
########## lucene/demo/src/java/org/apache/lucene/demo/facet/SandboxFacetsExample.java: ########## @@ -130,6 +135,88 @@ void index() throws IOException { IOUtils.close(indexWriter, taxoWriter); } + /** + * Example for {@link FacetBuilder} usage - simple API that provides results in a format very + * similar to classic facets module. It doesn't give all flexibility available with {@link + * org.apache.lucene.sandbox.facet.cutters.FacetCutter} and {@link + * org.apache.lucene.sandbox.facet.recorders.FacetRecorder} though, see below for lower level API + * usage examples. + */ + private List<FacetResult> simpleFacetsWithSearch() throws IOException { + //// init readers and searcher + DirectoryReader indexReader = DirectoryReader.open(indexDir); + IndexSearcher searcher = new IndexSearcher(indexReader); + TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir); + + //// build facets requests + FacetBuilder authorFacetBuilder = + new TaxonomyFacetBuilder(config, taxoReader, "Author").withTopN(10); + FacetBuilder priceFacetBuilder = + LongRangeFacetBuilder.create( + "Price", + new LongRange("0-10", 0, true, 10, true), + new LongRange("10-20", 10, true, 20, true)); + + //// Main hits collector + TopScoreDocCollectorManager hitsCollectorManager = + new TopScoreDocCollectorManager(2, Integer.MAX_VALUE); + + //// Search and collect + TopDocs topDocs = + new FacetOrchestrator() Review Comment: Each `FacetBuilder` can have its own topN value set by `withTopN()`, which is used to compute `FacetBuilder#getResult` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org