[
https://issues.apache.org/jira/browse/LUCENE-9444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17171518#comment-17171518
]
Michael McCandless commented on LUCENE-9444:
--------------------------------------------
Actually, I think a dedicated helper class makes sense? I like that approach.
Because, if we add that 3rd {{BinaryDocValues}} argument then the caller needs
to figure out how to create that themselves?
The ctor of this helper class could take a {{FacetsConfig}} and a {{dim}} and
it'd look up which indexed field has the encoded {{BinaryDocValues}}, and then
provide a method where you could pass a {{LeafReaderContext}} and it returns
another class for actually iterating over the {{FacetLabel}} for each document
in that segment?
Perhaps even {{dim}} should be optional so you could efficiently make a single
pass over all {{FacetLabel}} for that document.
Instead of {{FacetLabel[]}} maybe we could do something similar to how
{{SortedSetDocValues}} iterates over multiple {{int}} ordinals per document,
with a per-document {{nextOrd}} iterator? So we could have a
{{nextFacetLabel}} method letting you step through all {{FacetLabel}} for the
document?
> Need an API to easily fetch facet labels for a field in a document
> ------------------------------------------------------------------
>
> Key: LUCENE-9444
> URL: https://issues.apache.org/jira/browse/LUCENE-9444
> Project: Lucene - Core
> Issue Type: Improvement
> Components: modules/facet
> Affects Versions: 8.6
> Reporter: Ankur
> Priority: Major
>
> A facet field may be included in the list of fields whose values are to be
> returned for each hit.
> In order to get the facet labels for each hit we need to
> # Create an instance of _DocValuesOrdinalsReader_ and invoke
> _getReader(LeafReaderContext context)_ method to obtain an instance of
> _OrdinalsSegmentReader()_
> # _OrdinalsSegmentReader.get(int docID, IntsRef ordinals)_ method is then
> used to fetch and decode the binary payload in the document's BinaryDocValues
> field. This provides the ordinals that refer to facet labels in the
> taxonomy.**
> # Lastly TaxonomyReader.getPath(ord) is used to fetch the labels to be
> returned.
>
> Ideally there should be a simple API - *String[] getLabels(docId)* that hides
> all the above details and gives us the string labels. This can be part of
> *TaxonomyFacets* but that's just one idea.
> I am opening this issue to get community feedback and suggestions.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]