Yuti-G commented on code in PR #1035: URL: https://github.com/apache/lucene/pull/1035#discussion_r965481865
########## lucene/CHANGES.txt: ########## @@ -52,6 +52,8 @@ Improvements * LUCENE-10614: Properly support getTopChildren in RangeFacetCounts. (Yuting Gan) +* LUCENE-10652: Add a top-n range faceting example to RangeFacetsExample. (Yuting Gan) Review Comment: Yes, thanks! ########## lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java: ########## @@ -73,6 +77,31 @@ public void index() throws IOException { indexWriter.addDocument(doc); } + // Add documents with a fake timestamp for the past 7 days (24 * 7 = 168 hours), 3600 sec (1 + // hour) from "now", 7200 sec (2 hours) from "now", ...: + long startTime = 0; + for (int i = 0; i < 168; i++) { + long endTime = (i + 1) * 3600; + // Choose a relatively large number, e,g., "35", to create variation in count for + // the top n children, so that calling getTopChildren(10) can return top 10 children with + // different counts + for (int j = 0; j < i % 35; j++) { + Document doc = new Document(); + Random r = new Random(); + // Randomly generate a timestamp within the current range + long randomTimestamp = r.nextLong(1, endTime - startTime) + startTime; + // Add as doc values field, so we can compute range facets: + doc.add(new NumericDocValuesField("error timestamp", randomTimestamp)); + doc.add( + new StringField( + "Error message", "Server encountered error at " + randomTimestamp, Field.Store.NO)); Review Comment: Sure, addressed in the new revision. Thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org