Solr
  1. Solr
  2. SOLR-4504

CurrencyField treats docs w/o value the same as having a value of 0.0

    Details

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

      Description

      As noted by Gerald Blank on the mailing list, CurrencyField queries treat documents w/o any value the same as documents wit ha value of 0.0f.

      observe that using the example solr schema, with any number of docs indexed, this query matches all docs even though no docs have any values at all for hte specified field...

      http://localhost:8983/solr/select?q=hoss_c:[*%20TO%20*]
      

        Issue Links

          Activity

          Hide
          Hoss Man added a comment -

          The problem is that unlike a simple TrieField that uses FieldCacheRangeFilter (which knows about docs that have no value) CurrencyField needs to use a ValueSourceRangeFilter wrapped arround the CurrencyValueSource that computes the exchange rate.

          Attached patch fixes things by combining it with a FieldValueFilter and updates the existing range query test to include lots of docs with no field value. This seemed to expose another bug in CurrencyValueSource where you could get an ArrayIndexOutOfBoundsException because the ord(doc) value of the currency for a doc w/o values would be negative, which i fixed with an short-circut delegating to amounts.exist(doc)

          (4.1 users, even those with docs missing the currency field, wouldn't ever get the ArrayIndexOutOfBoundsException because in 4.1 the FieldCache.DocTermsIndex used "0" – instead of "-1" as it is returned by ord() now with the new DocValues APIs)

          Show
          Hoss Man added a comment - The problem is that unlike a simple TrieField that uses FieldCacheRangeFilter (which knows about docs that have no value) CurrencyField needs to use a ValueSourceRangeFilter wrapped arround the CurrencyValueSource that computes the exchange rate. Attached patch fixes things by combining it with a FieldValueFilter and updates the existing range query test to include lots of docs with no field value. This seemed to expose another bug in CurrencyValueSource where you could get an ArrayIndexOutOfBoundsException because the ord(doc) value of the currency for a doc w/o values would be negative, which i fixed with an short-circut delegating to amounts.exist(doc) (4.1 users, even those with docs missing the currency field, wouldn't ever get the ArrayIndexOutOfBoundsException because in 4.1 the FieldCache.DocTermsIndex used "0" – instead of "-1" as it is returned by ord() now with the new DocValues APIs)
          Hide
          Commit Tag Bot added a comment -

          [trunk commit] Chris M. Hostetter
          http://svn.apache.org/viewvc?view=revision&revision=1450304

          SOLR-4504: Fixed CurrencyField range queries to correctly exclude documents w/o values

          Show
          Commit Tag Bot added a comment - [trunk commit] Chris M. Hostetter http://svn.apache.org/viewvc?view=revision&revision=1450304 SOLR-4504 : Fixed CurrencyField range queries to correctly exclude documents w/o values
          Hide
          Hoss Man added a comment -

          Committed revision 1450304.
          Committed revision 1450331.

          Show
          Hoss Man added a comment - Committed revision 1450304. Committed revision 1450331.
          Hide
          Commit Tag Bot added a comment -

          [branch_4x commit] Chris M. Hostetter
          http://svn.apache.org/viewvc?view=revision&revision=1450331

          SOLR-4504: Fixed CurrencyField range queries to correctly exclude documents w/o values (merge r1450304)

          Show
          Commit Tag Bot added a comment - [branch_4x commit] Chris M. Hostetter http://svn.apache.org/viewvc?view=revision&revision=1450331 SOLR-4504 : Fixed CurrencyField range queries to correctly exclude documents w/o values (merge r1450304)
          Hide
          Uwe Schindler added a comment -

          Closed after release.

          Show
          Uwe Schindler added a comment - Closed after release.

            People

            • Assignee:
              Hoss Man
              Reporter:
              Hoss Man
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development