Lucene - Core
  1. Lucene - Core
  2. LUCENE-4514

Make Scorer.freq() well defined: number of matches in doc

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1, 6.0
    • Component/s: core/query/scoring
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Today Scorer.freq() is somewhat useless: because in general it returns the number of matches, but other times it returns a strange floating point value (essentially an intermediate score).

      I think it should just return the number of matches in the document. This makes it well-defined and useful to consumers (e.g. if they are going to iterate over the positions or whatever in the future).

         /** Returns number of matches for the current document.
      -   *  This returns a float (not int) because
      -   *  SloppyPhraseScorer discounts its freq according to how
      -   *  "sloppy" the match was.
          *
          * @lucene.experimental */
      -  public abstract float freq() throws IOException;
      +  public abstract int freq() throws IOException;
      

        Activity

        Hide
        Michael McCandless added a comment -

        +1

        Show
        Michael McCandless added a comment - +1
        Hide
        Robert Muir added a comment -

        prototype patch: core tests pass.

        Really to make the SloppyPhraseScorer cleaner I think we should (unrelated) collapse it into the abstract PhraseScorer, of which its the only subclass now that ExactPhraseScorer extends Scorer directly.

        Show
        Robert Muir added a comment - prototype patch: core tests pass. Really to make the SloppyPhraseScorer cleaner I think we should (unrelated) collapse it into the abstract PhraseScorer, of which its the only subclass now that ExactPhraseScorer extends Scorer directly.
        Hide
        Michael McCandless added a comment -

        Patch looks good!

        Really to make the SloppyPhraseScorer cleaner I think we should (unrelated) collapse it into the abstract PhraseScorer, of which its the only subclass now that ExactPhraseScorer extends Scorer directly.

        +1

        Show
        Michael McCandless added a comment - Patch looks good! Really to make the SloppyPhraseScorer cleaner I think we should (unrelated) collapse it into the abstract PhraseScorer, of which its the only subclass now that ExactPhraseScorer extends Scorer directly. +1
        Hide
        Robert Muir added a comment -

        OK i did this piece too: /lucene/dev/branches/cleanup2878

        I guess i thought it would be harder: but i just did a rote refactoring.

        Show
        Robert Muir added a comment - OK i did this piece too: /lucene/dev/branches/cleanup2878 I guess i thought it would be harder: but i just did a rote refactoring.
        Hide
        Michael McCandless added a comment -

        +1

        Show
        Michael McCandless added a comment - +1
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] Robert Muir
        http://svn.apache.org/viewvc?view=revision&revision=1403789

        LUCENE-4514: Make Scorer.freq() well defined: number of matches in doc

        Show
        Commit Tag Bot added a comment - [branch_4x commit] Robert Muir http://svn.apache.org/viewvc?view=revision&revision=1403789 LUCENE-4514 : Make Scorer.freq() well defined: number of matches in doc

          People

          • Assignee:
            Unassigned
            Reporter:
            Robert Muir
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development