Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-13156

Limiting field facet with certain terms via {!terms} not taking into account sorting

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.7, 8.0, master (9.0)
    • Component/s: Facet Module
    • Labels:
      None

      Description

      When I'm doing limiting facet keys with {!terms} it doesn't take into account sorting.

      First query not limiting the facet keys:

      facet.field=title&facet.sort=count&facet=on&q=:

      Response as expected:

      "facet_counts":{ "facet_queries":{}, "facet_fields":{ "title":[ "book2",3, "book1",2, "book3",1]}, "facet_ranges":{}, "facet_intervals":{}, "facet_heatmaps":}}

       

      When doing it with limiting:

      facet.field={!terms=Book3,Book2,Book1}title&facet.sort=count&facet=on&q=:

      I'm getting the exact order of how I list terms:

      "facet_counts":{ "facet_queries":{}, "facet_fields":{ "title":[ "Book3",1, "Book2",3, "Book1",2]}, "facet_ranges":{}, "facet_intervals":{}, "facet_heatmaps":}}

      I've looked at the code, and it's clearly an issue there:

       

      org.apache.solr.request.SimpleFacets#getListedTermCounts

       

      for (String term : terms) {
          int count = searcher.numDocs(ft.getFieldQuery(null, sf, term), parsed.docs);
          res.add(term, count);
      }

       

      it's just basically iterating over terms and don't do any sorting at all. 

       

       

        Attachments

        1. SOLR-13156.patch
          8 kB
          Mikhail Khludnev
        2. SOLR-13156.patch
          6 kB
          Konstantin Perikov

          Activity

            People

            • Assignee:
              mkhl Mikhail Khludnev
              Reporter:
              mysterion Konstantin Perikov
            • Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: