Lucene - Core
  1. Lucene - Core
  2. LUCENE-2854

Deprecate SimilarityDelegator and Similarity.lengthNorm

    Details

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

      Description

      SimilarityDelegator is a back compat trap (see LUCENE-2828).

      Apps should just [statically] subclass Sim or DefaultSim; if they really need "runtime subclassing" then they can make their own app-level delegator.

      Also, Sim.computeNorm subsumes lengthNorm, so we should deprecate lengthNorm in favor of computeNorm.

      1. LUCENE-2854.patch
        63 kB
        Michael McCandless
      2. LUCENE-2854_fuzzylikethis.patch
        3 kB
        Robert Muir

        Activity

        Hide
        Grant Ingersoll added a comment -

        Bulk close for 3.1

        Show
        Grant Ingersoll added a comment - Bulk close for 3.1
        Hide
        Michael McCandless added a comment -

        Is it possible to remove this method Query.getSimilarity also? I don't understand why we need this method!

        I would love to! But I think that's for another day...

        I looked into this and got stuck with BoostingQuery, which rewrites to an anon subclass of BQ overriding its getSimilarity in turn override its coord method. Rather twisted... if we can do this differently I think we could remove Query.getSimilarity.

        Show
        Michael McCandless added a comment - Is it possible to remove this method Query.getSimilarity also? I don't understand why we need this method! I would love to! But I think that's for another day... I looked into this and got stuck with BoostingQuery, which rewrites to an anon subclass of BQ overriding its getSimilarity in turn override its coord method. Rather twisted... if we can do this differently I think we could remove Query.getSimilarity.
        Hide
        Robert Muir added a comment -

        Is it possible to remove this method Query.getSimilarity also? I don't understand why we need this method!

          /** Expert: Returns the Similarity implementation to be used for this query.
           * Subclasses may override this method to specify their own Similarity
           * implementation, perhaps one that delegates through that of the Searcher.
           * By default the Searcher's Similarity implementation is returned.*/
        
        Show
        Robert Muir added a comment - Is it possible to remove this method Query.getSimilarity also? I don't understand why we need this method! /** Expert: Returns the Similarity implementation to be used for this query. * Subclasses may override this method to specify their own Similarity * implementation, perhaps one that delegates through that of the Searcher. * By default the Searcher's Similarity implementation is returned.*/
        Hide
        Robert Muir added a comment -

        here is the patch for fuzzylikethis for trunk... so you can remove the delegator completely in trunk.

        Show
        Robert Muir added a comment - here is the patch for fuzzylikethis for trunk... so you can remove the delegator completely in trunk.
        Hide
        Michael McCandless added a comment -

        The above patch applies to 3.x

        For trunk I plan to remove SimliarityDelegator from core, and move it (deprecated) into contrib/queries/... (private to FuzzyLikeThisQ). At some point [later] we can fix FuzzyLikeThisQ to not use it...

        Show
        Michael McCandless added a comment - The above patch applies to 3.x For trunk I plan to remove SimliarityDelegator from core, and move it (deprecated) into contrib/queries/... (private to FuzzyLikeThisQ). At some point [later] we can fix FuzzyLikeThisQ to not use it...
        Hide
        Michael McCandless added a comment -

        I think we should simply make a hard break on the Sim.lengthNorm ->
        computeNorm cutover. Subclassing sim is an expert thing, and, I'd
        rather apps see a compilation error on upgrade so that they realize
        their lengthNorm wasn't being called this whole time because of
        LUCENE-2828 (and that they must now cutover to computeNorm).

        So I made lengthNorm final (and throws UOE), computeNorm abstract. I
        deprecated SimilarityDelegator, and fixed BQ to not use it anymore.
        The only other use is FuzzyLikeThisQuery, but fixing that is a little
        too involved for today.

        Show
        Michael McCandless added a comment - I think we should simply make a hard break on the Sim.lengthNorm -> computeNorm cutover. Subclassing sim is an expert thing, and, I'd rather apps see a compilation error on upgrade so that they realize their lengthNorm wasn't being called this whole time because of LUCENE-2828 (and that they must now cutover to computeNorm). So I made lengthNorm final (and throws UOE), computeNorm abstract. I deprecated SimilarityDelegator, and fixed BQ to not use it anymore. The only other use is FuzzyLikeThisQuery, but fixing that is a little too involved for today.

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael McCandless
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development