## org.apache.lucene.search
Class ConstantScoreQuery.ConstantScorer

    java.lang.Object
      org.apache.lucene.search.Scorer
          org.apache.lucene.search.ConstantScoreQuery.ConstantScorer

Enclosing class:
  ConstantScoreQuery

    protected class ConstantScoreQuery.ConstantScorer

extends Scorer

Constructor Summary
`ConstantScoreQuery.ConstantScorer(Similarity similarity, IndexReader reader, Weight w)`

Method Summary
`int` `doc()` Returns the current document number matching the query.
`Explanation` `explain(int doc)` Returns an explanation of the score for a document.
`boolean` `next()` Advances to the document matching this Scorer with the lowest doc Id greater than the current value of `Scorer.doc()` (or to the matching document with the lowest doc Id if next has never been called on this Scorer).
`float` `score()` Returns the score of the current document matching the query.
`boolean` `skipTo(int target)` Skips to the document matching this Scorer with the lowest doc Id greater than or equal to a given target.

Methods inherited from class org.apache.lucene.search.Scorer
`getSimilarity, score, score`

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

Constructor Detail

### ConstantScoreQuery.ConstantScorer

    public ConstantScoreQuery.ConstantScorer(Similarity similarity,
                                             IndexReader reader,
                                             Weight w)
                                      throws IOException

Throws:
  `IOException`

Method Detail

### next

    public boolean next()
                 throws IOException

  Description copied from class: `Scorer`
  Advances to the document matching this Scorer with the lowest doc Id greater than the current value of `Scorer.doc()` (or to the matching document with the lowest doc Id if next has never been called on this Scorer).

  When this method is used the `Scorer.explain(int)` method should not be used.

  Specified by:
    `next` in class `Scorer`
  Returns:
    true iff there is another document matching the query.
  Throws:
    `IOException`
  See Also:
    `BooleanQuery.setAllowDocsOutOfOrder(boolean)`

### doc

    public int doc()

  Description copied from class: `Scorer`
  Returns the current document number matching the query. Initially invalid, until `Scorer.next()` is called the first time.

  Specified by:
    `doc` in class `Scorer`

### score

    public float score()
                throws IOException

  Description copied from class: `Scorer`
  Returns the score of the current document matching the query. Initially invalid, until `Scorer.next()` or `Scorer.skipTo(int)` is called the first time.

  Specified by:
    `score` in class `Scorer`
  Throws:
    `IOException`

### skipTo

    public boolean skipTo(int target)
                   throws IOException

  Description copied from class: `Scorer`
  Skips to the document matching this Scorer with the lowest doc Id greater than or equal to a given target.

  The behavior of this method is undefined if the target specified is less than or equal to the current value of `Scorer.doc()`.

  Behaves as if written:

         boolean skipTo(int target) {
           do {
             if (!next())
                   return false;
           } while (target > doc());
           return true;
         }

  Most implementations are considerably more efficient than that.

  When this method is used the `Scorer.explain(int)` method should not be used.

  Specified by:
    `skipTo` in class `Scorer`
  Parameters:
    `target` - The target document number.
  Returns:
    true iff there is such a match.
  Throws:
    `IOException`
  See Also:
    `BooleanQuery.setAllowDocsOutOfOrder(boolean)`

### explain

    public Explanation explain(int doc)
                        throws IOException

  Description copied from class: `Scorer`
  Returns an explanation of the score for a document.
  When this method is used, the `Scorer.next()`, `Scorer.skipTo(int)` and `Scorer.score(HitCollector)` methods should not be used.

  Specified by:
    `explain` in class `Scorer`
  Parameters:
    `doc` - The document number for the explanation.
  Throws:
    `IOException`

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