Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-9444

Need an API to easily fetch facet labels for a field in a document

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 8.6
    • 9.0, 8.7
    • modules/facet
    • 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

      1. Create an instance of DocValuesOrdinalsReader and invoke getReader(LeafReaderContext context) method to obtain an instance of OrdinalsSegmentReader()
      2. 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.**
      3. 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.

       

      Attachments

        1. LUCENE-9444.patch
          16 kB
          Michael McCandless
        2. LUCENE-9444.v2.patch
          16 kB
          Ankur
        3. LUCENE-9444.patch
          15 kB
          Ankur

        Activity

          People

            Unassigned Unassigned
            goankur Ankur
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 5h 10m
                5h 10m