Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
8.6
-
New, Patch Available
Description
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.