Lucene - Core
  1. Lucene - Core
  2. LUCENE-5045

DrillSideways.search yields IllegalArgEx if given IndexReader is empty

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.4, 6.0
    • Component/s: modules/facet
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      DrillSideways.create() creates either TopScoreDocCollector or TopFieldCollector with numHits = min(topN, reader.maxDoc()). When the reader is empty, these collectors throw IllegalArgEx that numHits should be > 0. While this is a correct behavior on their part, I think the behavior in DS is wrong. It's an optimization to ask for min(topN, reader.maxDoc(), i.e. if it just delegated topN all was well. So if we'd like to keep the optimization, we should at least make it min(topN,maxDoc+1), because there's nothing technically wrong from running a search against an empty index.

      1. LUCENE-5045.patch
        5 kB
        Shai Erera
      2. LUCENE-5045.patch
        5 kB
        Shai Erera

        Activity

        Hide
        Shai Erera added a comment -

        Patch adds a test which reproduces the problem and fixes DS to modify topN to min(topN,maxDoc) only if maxDoc > 0.

        I intend to commit it shortly.

        Show
        Shai Erera added a comment - Patch adds a test which reproduces the problem and fixes DS to modify topN to min(topN,maxDoc) only if maxDoc > 0. I intend to commit it shortly.
        Hide
        Shai Erera added a comment -

        I made the topN decision just like IndexSearcher.

        Show
        Shai Erera added a comment - I made the topN decision just like IndexSearcher.
        Hide
        Michael McCandless added a comment -

        +1, thanks Shai!

        Show
        Michael McCandless added a comment - +1, thanks Shai!
        Hide
        Shai Erera added a comment -

        Committed to trunk and 4x.

        Show
        Shai Erera added a comment - Committed to trunk and 4x.
        Hide
        Steve Rowe added a comment -

        Bulk close resolved 4.4 issues

        Show
        Steve Rowe added a comment - Bulk close resolved 4.4 issues

          People

          • Assignee:
            Shai Erera
            Reporter:
            Shai Erera
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development