I am trying to move from lucene 2.4 to 4.4. I had used bobo-browse for
faceting in 2.4.
I used below code (from Lucene examples) to query documents and get facets.
List<FacetRequest> categories = new ArrayList<FacetRequest>();
categories.add(new CountFacetRequest(new CategoryPath("CATEGORY_PATH",
'/'), 10));
FacetSearchParams searchParams = new FacetSearchParams(categories);
TopScoreDocCollector topScoreDocCollector =
TopScoreDocCollector.create(200, true);
FacetsCollector facetsCollector = FacetsCollector.create(searchParams,
indexReader, taxonomyReader);
indexSearcher.search(new MatchAllDocsQuery(),
MultiCollector.wrap(topScoreDocCollector, facetsCollector));
Above code gives me results along with facets.
Now I want to add a Sort field on document, say I want to sort by name. I
can achieve this using following
Sort sort = new Sort(new SortField("NAME", Type.STRING));
TopFieldDocs docs = indexSearcher.search(new MatchAllDocsQuery(), 100,
sort);
Now, how do I achieve sorting along with faceting, because there is no
method in IndexSearcher which has Collector and Sort.
I have asked this question on stackoverflow as well. (
http://stackoverflow.com/questions/17992183/lucene-4-faceted-search-with-sorting
)
Please Help !!