Yuti-G commented on code in PR #914: URL: https://github.com/apache/lucene/pull/914#discussion_r900427946
########## lucene/facet/src/java/org/apache/lucene/facet/sortedset/AbstractSortedSetDocValueFacetCounts.java: ########## @@ -72,6 +72,40 @@ public FacetResult getTopChildren(int topN, String dim, String... path) throws I return createFacetResult(topChildrenForPath, dim, path); } + @Override + public FacetResult getAllChildren(String dim, String... path) throws IOException { + FacetsConfig.DimConfig dimConfig = stateConfig.getDimConfig(dim); + + if (dimConfig.hierarchical) { + int pathOrd = (int) dv.lookupTerm(new BytesRef(FacetsConfig.pathToString(dim, path))); + if (pathOrd < 0) { + // path was never indexed + return null; + } + SortedSetDocValuesReaderState.DimTree dimTree = state.getDimTree(dim); + return getPathResult(dimConfig, dim, path, pathOrd, dimTree.iterator(pathOrd)); + } else { + if (path.length > 0) { + throw new IllegalArgumentException( + "Field is not configured as hierarchical, path should be 0 length"); + } + OrdRange ordRange = state.getOrdRange(dim); + if (ordRange == null) { + // means dimension was never indexed + return null; + } + int dimOrd = ordRange.start; + PrimitiveIterator.OfInt childIt = ordRange.iterator(); + if (dimConfig.multiValued && dimConfig.requireDimCount) { + // If the dim is multi-valued and requires dim counts, we know we've explicitly indexed + // the dimension and we need to skip past it so the iterator is positioned on the first + // child: + childIt.next(); + } + return getPathResult(dimConfig, dim, null, dimOrd, childIt); + } + } Review Comment: Thanks for the suggestion! -- 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