gsmiller commented on code in PR #1035:
URL: https://github.com/apache/lucene/pull/1035#discussion_r965402810
##########
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:
very minor: could we make this all lower case just to be consistent with the
`error timestamp` field name?
##########
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:
OK, I think it makes sense for this to release with 10.0. This is because we
rely on getTopChildren functionality, which is going to change with 10.0 to
actually be "top" children and not "all" children. So we'll release this demo
functionality with 10.0. Is that your thinking here too? Just trying to refresh
my memory on this change.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]