lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cam Bazz <>
Subject simple facet search
Date Mon, 19 Sep 2016 04:28:12 GMT

I have a field called timeSlot in my documents, basically representing an

When a query is made, I would like to make a graph of how many doc hits
corresponds to each timeSlot, sort it and display a chart of it.

I am simply using term queries, to query StringFields, and here is my
relevant search code:

            IndexSearcher searcher = new IndexSearcher(reader);
            TermQuery termQuery = new TermQuery(new Term(fieldName,

            SortField sF = new SortField("beginTime", Type.LONG, true);
            Sort sort = new Sort(sF);

            results =, start + hitsPerPage,
            Integer numTotalHits = results.totalHits;
            ScoreDoc[] hits = results.scoreDocs;


How can I take advantage of Faceted searching in this scenario, to
facetCount field named timeSlot, simply?

I have looked over the example code at demo, which is using a taxonomy
reader/writer, but I could not figure out.

It appears we can consruct a FacetCollector, and provide it as an argument
to search like searcher.searc(query, 1000, facetCollector) - but then I
could not figure out how to get the facets and facet counts from that

I have done similar things in the past using solr, but I am stuck now.

Any ideas/help/recomendations greatly appreciated.

Best Regards,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message