Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-6425

Move extractTerms to Weight

Details

    • Task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 5.2, 6.0
    • None
    • None
    • New

    Description

      Today we have extractTerms on Query, but it is supposed to only be called after the query has been specialized to a given IndexReader using Query.rewrite(IndexReader) to allow some complex queries to replace terms "matchers" with actual terms (eg. WildcardQuery).

      However, we already have an abstraction for indexreader-specialized queries: Weight. So I think it would make more sense to have extractTerms on Weight. This would also remove the trap of calling extractTerms on a query which is not rewritten yet.

      Since Weights know about whether scores are needed or not, I also hope this would help improve the extractTerms semantics. We currently have 2 use-cases for extractTerms: distributed IDF and highlighting. While the former only cares about terms which are used for scoring, it could make sense to highlight terms that were used for matching, even if they did not contribute to the score (eg. if wrapped in a ConstantScoreQuery or a BooleanQuery FILTER clause). So highlighters could do searcher.createNormalizedWeight(query, false).extractTerms(termSet) to get all terms that were used for matching the query while distributed IDF would instead do searcher.createNormalizedWeight(query, true).extractTerms(termSet) to get scoring terms only.

      Attachments

        1. LUCENE-6425.patch
          63 kB
          Adrien Grand
        2. LUCENE-6425.patch
          64 kB
          Adrien Grand

        Activity

          People

            jpountz Adrien Grand
            jpountz Adrien Grand
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: