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

facet.threads can return wrong results when using facet.prefix multiple times on same field

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.9
    • Fix Version/s: 5.3, 6.0
    • Component/s: search
    • Labels:
      None

      Description

      When using facet.threads, SimpleFacets can return the wrong results when using facet.prefix multiple times on the same field.

      The problem is that SimpleFacets essentially stores the prefix value in a global variable, rather than passing the current prefix value into the Callable. So, the prefix value that is used when getting the term counts is whichever one was the last one parsed.

      STEPS TO REPRODUCE:

      1. Create a document with a string field named "myFieldName" and value "foo"
      2. Create another document with a string field named "myFieldName" and value "bar"
      3. Run this query:
        q=*:*&rows=0&facet=true&facet.field={!key=key1 facet.prefix=foo}myFieldName&facet.field={!key=key2 facet.prefix=bar}myFieldName&facet.threads=1

      EXPECTED:

      <lst name="facet_fields">
        <lst name="key1">
          <int name="foo">1</int>
        </lst>
        <lst name="key2">
          <int name="bar">1</int>
        </lst>
      </lst>

      ACTUAL:

      <lst name="facet_fields">
        <lst name="key1">
          <int name="bar">1</int>
        </lst>
        <lst name="key2">
          <int name="bar">1</int>
        </lst>
      </lst>

      I'm using 4.9, but I think this affects all versions.

      A user previously reported this here:
      http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201405.mbox/%3CBAY169-W52CEF09187A88286DE5417D5270@phx.gbl%3E

      I think this affects parameters other than facet.prefix, but I have not tried that yet.

        Attachments

        1. SOLR-6686.patch
          33 kB
          Tim Underwood
        2. SOLR-6686.patch
          36 kB
          Shalin Shekhar Mangar
        3. SOLR-6686.patch
          73 kB
          Shalin Shekhar Mangar

          Issue Links

            Activity

              People

              • Assignee:
                shalinmangar Shalin Shekhar Mangar
                Reporter:
                michaelryan Michael Ryan
              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: