2 * Copyright 2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 namespace Lucene
.Net
.Search
20 /// <summary>Expert: Implements scoring for a class of queries. </summary>
21 public abstract class Scorer
23 private Similarity similarity
;
25 /// <summary>Constructs a Scorer. </summary>
26 protected internal Scorer(Similarity similarity
)
28 this.similarity
= similarity
;
31 /// <summary>Returns the Similarity implementation used by this scorer. </summary>
32 public virtual Similarity
GetSimilarity()
34 return this.similarity
;
37 /// <summary>Scores all documents and passes them to a collector. </summary>
38 public virtual void Score(HitCollector hc
)
42 hc
.Collect(Doc(), Score());
46 /// <summary>Advance to the next document matching the query. Returns true iff there
49 public abstract bool Next();
51 /// <summary>Returns the current document number. Initially invalid, until {@link
52 /// #Next()} is called the first time.
54 public abstract int Doc();
56 /// <summary>Returns the score of the current document. Initially invalid, until
57 /// {@link #Next()} is called the first time.
59 public abstract float Score();
61 /// <summary>Skips to the first match beyond the current whose document number is
62 /// greater than or equal to <i>target</i>. <p>Returns true iff there is such
63 /// a match. <p>Behaves as if written: <pre>
64 /// boolean SkipTo(int target) {
68 /// } while (target > doc());
72 /// Most implementations are considerably more efficient than that.
74 public abstract bool SkipTo(int target
);
76 /// <summary>Returns an explanation of the score for <code>doc</code>. </summary>
77 public abstract Explanation
Explain(int doc
);