gsmiller commented on a change in pull request #747: URL: https://github.com/apache/lucene/pull/747#discussion_r828050128
########## File path: lucene/facet/src/java/org/apache/lucene/facet/sortedset/SortedSetDocValuesFacetCounts.java ########## @@ -190,20 +235,45 @@ private FacetResult getPathResult( String[] parts = FacetsConfig.stringToPath(term.utf8ToString()); labelValues[i] = new LabelAndValue(parts[parts.length - 1], ordAndValue.value); } + return labelValues; + } - if (dimConfig.hierarchical == false) { + /** Returns value/count of a dimension. */ + private Number getDimValue( Review comment: I see what you're saying here. It seems like there are three cases here: 1. We've explicitly indexed a count for the dimension (because it's hierarchical or multivalued and we've signaled that we require dim counts in FacetsConfig). In this case, `getDimValue` can simply return the indexed count. 2. We have not indexed a count for the dimension and we need to compute it by aggregating over the children. If the refinement is configured as multivalued and we _didn't_ configure it as needing dim counts, we can't do that accurately and need to communicate back to the caller that we cannot compute an accurate count for the dim. Right now your code is doing this by returning `-1`, which I think makes sense. 3. We have not indexed a count and need to compute it, and the dimension is _not_ configured as multivalued. So we can accurately compute a count by aggregating over the children. In this case, we should just always return that count. It looks like your implementation right now is effectively special-casing the situation where there are no children (i.e., the PQ is null), but I think you should just return `0` there (i.e., just return `childOrdsResult.dimCount`). Returning `0` is the correct behavior since the value is actually `0` when there are no children. So instead of returning `null` or `-1`, I would suggest always returning `childOrdsResult.dimCount`. -- 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