Lucene - Core
  1. Lucene - Core
  2. LUCENE-3208

Move Query.weight() to IndexSearcher as protected method

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3, 4.0-ALPHA
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      We had this issue several times, latest in LUCENE-3207.

      The method Query.weight() was left in Query for backwards reasons in Lucene 2.9 when we changed Weight class. This method is only to be called on top-level queries - and this is done by IndexSearcher. This method is just a utility method, that has nothing to do with the query itsself (it just combines the createWeight method and calls the normalization afterwards).

      The problem we have is that any query that wraps other queries (like CustomScore, ConstantScore, Boolean) calls Query.weight() instead of Query.createWeight(), it will do normalization two times, leading to strange bugs.

      For 3.3 I will make Query.weight() simply delegate to IndexSearcher's replacement method with a big deprecation warning, so user sees this. In IndexSearcher itsself the method will be protected to only be called by itsself or subclasses of IndexSearcher. Delegation for backwards is no problem, as protected is accessible by classes in same package.

      I would suggest the method name to be IndexSearcher.createNormalizedWeight(Query q)

      1. LUCENE-3208.patch
        25 kB
        Uwe Schindler
      2. LUCENE-3208.patch
        19 kB
        Uwe Schindler
      3. LUCENE-3208.patch
        17 kB
        Uwe Schindler
      4. LUCENE-3208-3x.patch
        34 kB
        Uwe Schindler
      5. LUCENE-3208-3x.patch
        34 kB
        Uwe Schindler
      6. LUCENE-3208-LTC.patch
        3 kB
        Uwe Schindler

        Issue Links

          Activity

          Uwe Schindler created issue -
          Uwe Schindler made changes -
          Field Original Value New Value
          Link This issue breaks LUCENE-3207 [ LUCENE-3207 ]
          Uwe Schindler made changes -
          Attachment LUCENE-3208.patch [ 12482776 ]
          Uwe Schindler made changes -
          Attachment LUCENE-3208.patch [ 12482788 ]
          Uwe Schindler made changes -
          Attachment LUCENE-3208-LTC.patch [ 12482809 ]
          Uwe Schindler made changes -
          Attachment LUCENE-3208.patch [ 12482827 ]
          Uwe Schindler made changes -
          Attachment LUCENE-3208-3x.patch [ 12482866 ]
          Uwe Schindler made changes -
          Attachment LUCENE-3208-3x.patch [ 12482868 ]
          Uwe Schindler made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Robert Muir made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Uwe Schindler
              Reporter:
              Uwe Schindler
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development