• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

facet count in lucene9.12

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using lucene 9.12 for my project I want to do facet with facet criteria and time range query
I refer many sites and check many combinations but all won't help me on this. Anyone please suggest to achieve facet count with facet and time criteria.

Here I have attached my sample code
public void dotestSearch(IndexReader reader){
System.out.println("NewFacetingImpl:: dotestSearch");
       try
       {
FacetsConfig facetsConfig = new FacetsConfig();
IndexSearcher searcher = new IndexSearcher(reader);
               Query timeRangeQuery = LongPoint.newRangeQuery("timestamp",startDate,endDate);
DrillDownQuery drillDownQuery = new DrillDownQuery(facetsConfig);
drillDownQuery.add("category", "electronics");
drillDownQuery.add("timestamp", timeRangeQuery);
System.out.println("facet Query:: "+drillDownQuery);

// Create a DefaultSortedSetDocValuesReaderState for the "category" facet
       SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader);

// Collect facets from the matching documents
        FacetsCollector facetsCollector = new FacetsCollector();
        FacetsCollector.search(searcher, drillDownQuery, 10, facetsCollector);

        SortedSetDocValuesFacetCounts srcFacetCounts = new SortedSetDocValuesFacetCounts(state, facetsCollector);

        // Get the facet results for the brand field
//Facets facets = new SortedSetDocValuesFacetCounts(state, facetsCollector);
        FacetResult result = srcFacetCounts.getTopChildren(10, "brand");


       System.out.println(" facet counts for dst facet");
        if (result != null) {
            for (LabelAndValue lv : result.labelValues) {
               System.out.println(lv.label + ": " + lv.value);
            }
        } else {
            System.out.println("No results found.");
        }

}
       catch(Exception e)
       {
           e.printStackTrace();
       }
  }

thanks inadvance!
 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic