/// <summary>User runs a query and counts facets.</summary>
        private IList <FacetResult> Search()
        {
            using 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);

            IList <FacetResult> results = new List <FacetResult>
            {
                facets.GetTopChildren(10, "Author"),
                facets.GetTopChildren(10, "Publish Year")
            };

            return(results);
        }
        /// <summary>User drills down on 'Publish Year/2010'.</summary>
        private FacetResult DrillDown()
        {
            using 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");

            return(result);
        }