Introduction to the problem
I use the Apache's Lucene for java and I'd like to know how to drill-down automatically in a faceted search. More precisely, I want to, given a level of the taxonomy, get the facets of that level. For instance, if I use the Open Directory Project as a taoxnomy and I look for theatre at level 2 I want to drill-down in the taxonomy taking the path with more weight. In this case: Arts->performing_arts. This way I'll get a facted search for the categories inside performing_arts.
Problem
I know hot to make a faceted search. In the example above I would do:
// 2. Query expansion
IndexSearcher wnSearcher = new IndexSearcher(wnReader);
//Query q = SynLookup.expand(querystr, wnSearcher, analyzer, "Contents", (float) 0.9);
// 3. Query
// the "title" arg specifies the default field to use
// when no field is explicitly specified in the query.
Query q = new QueryParser(Version.LUCENE_36, "Contents", analyzer).parse(querystr);
// 3. search
Query matchAllDocs= new MatchAllDocsQuery();
// Create the facets collector
FacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
FacetSearchParams facetSearchParams = new FacetSearchParams(indexingParams);
CategoryPath top = new CategoryPath("Top/Arts/performing_arts",'/');
FacetRequest neighborhoodFacetRequest = new CountFacetRequest(top, 13);
facetSearchParams.addFacetRequest(neighborhoodFacetRequest);
FacetsCollector fc = new FacetsCollector(facetSearchParams, reader, taxonomyReader);
IndexSearcher searcher = new IndexSearcher(reader);
searcher.search(q, new QueryWrapperFilter(matchAllDocs), fc);
// 4. display results
System.out.println("Results: ");
List<FacetResult> res = fc.getFacetResults();
printFacetResult(res);
However, I must know the path to create the CategoryPath a priori... And I don't know how to get the whole results set and then get to the level I want. If I set the CategoryPath to the Top I only get the results for the first level.
A solution would be to get first the results for the first level, add the category with the maximum weight to the path, then perform a new faceted search and so on. But that is very inefficient!
Thank you!