Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.search.highlight
Class QueryScorer

    java.lang.Object
      org.apache.lucene.search.highlight.QueryScorer

All Implemented Interfaces:
  Scorer

    public class QueryScorer

extends Object
implements Scorer

`Scorer` implementation which scores text fragments by the number of unique query terms found. This class uses the `QueryTermExtractor` class to process determine the query terms and their boosts to be used.

Author:
  mark@searcharea.co.uk

Constructor Summary
`QueryScorer(Query query)`
`QueryScorer(Query query, IndexReader reader, String fieldName)`
`QueryScorer(Query query, String fieldName)`
`QueryScorer(WeightedTerm[] weightedTerms)`

Method Summary
`void` | `allFragmentsProcessed()`
`float` | `getFragmentScore()` Called when the highlighter has no more tokens for the current fragment - the scorer returns the weighting it has derived for the most recent fragment, typically based on the tokens passed to getTokenScore().
`float` | `getMaxTermWeight()`
`float` | `getTokenScore(Token token)` Called for each token in the current fragment
`void` | `startFragment(TextFragment newFragment)` called when a new fragment is started for consideration

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### QueryScorer

    public QueryScorer(Query query)

Parameters:
  `query` - a Lucene query (ideally rewritten using query.rewrite before being passed to this class and the searcher)

### QueryScorer

    public QueryScorer(Query query,
                       String fieldName)

Parameters:
  `query` - a Lucene query (ideally rewritten using query.rewrite before being passed to this class and the searcher)
  `fieldName` - the Field name which is used to match Query terms

### QueryScorer

    public QueryScorer(Query query,
                       IndexReader reader,
                       String fieldName)

Parameters:
  `query` - a Lucene query (ideally rewritten using query.rewrite before being passed to this class and the searcher)
  `reader` - used to compute IDF which can be used to a) score selected fragments better b) use graded highlights eg set font color intensity
  `fieldName` - the field on which Inverse Document Frequency (IDF) calculations are based

### QueryScorer

    public QueryScorer(WeightedTerm[] weightedTerms)

Method Detail

### startFragment

    public void startFragment(TextFragment newFragment)

  Description copied from interface: `Scorer`
  called when a new fragment is started for consideration

  Specified by:
    `startFragment` in interface `Scorer`

### getTokenScore

    public float getTokenScore(Token token)

  Description copied from interface: `Scorer`
  Called for each token in the current fragment

  Specified by:
    `getTokenScore` in interface `Scorer`
  Parameters:
    `token` - The token to be scored
  Returns:
    a score which is passed to the Highlighter class to influence the mark-up of the text (this return value is NOT used to score the fragment)

### getFragmentScore

    public float getFragmentScore()

  Description copied from interface: `Scorer`
  Called when the highlighter has no more tokens for the current fragment - the scorer returns the weighting it has derived for the most recent fragment, typically based on the tokens passed to getTokenScore().

  Specified by:
    `getFragmentScore` in interface `Scorer`

### allFragmentsProcessed

    public void allFragmentsProcessed()

### getMaxTermWeight

    public float getMaxTermWeight()

  Returns:
    The highest weighted term (useful for passing to GradientFormatter to set top end of coloring scale.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.