Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / beagled / Lucene.Net / Search / Scorer.cs
blobf2760a7b4873b28688b5352e4ce64e536773f8e5
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
16 using System;
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)
40 while (Next())
42 hc.Collect(Doc(), Score());
46 /// <summary>Advance to the next document matching the query. Returns true iff there
47 /// is another match.
48 /// </summary>
49 public abstract bool Next();
51 /// <summary>Returns the current document number. Initially invalid, until {@link
52 /// #Next()} is called the first time.
53 /// </summary>
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.
58 /// </summary>
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) {
65 /// do {
66 /// if (!next())
67 /// return false;
68 /// } while (target > doc());
69 /// return true;
70 /// }
71 /// </pre>
72 /// Most implementations are considerably more efficient than that.
73 /// </summary>
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);