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.
18 using IndexReader
= Lucene
.Net
.Index
.IndexReader
;
20 namespace Lucene
.Net
.Search
23 /// <summary>Expert: Calculate query weights and build query scorers.
25 /// The purpose of Weight is to make it so that searching does not modify
26 /// a Query, so that a Query instance can be reused. <br>
27 /// Searcher dependent state of the query should reside in the Weight. <br>
28 /// IndexReader dependent state should reside in the Scorer.
30 /// A <code>Weight</code> is used in the following way:
32 /// <li>A <code>Weight</code> is constructed by a top-level query,
33 /// given a <code>Searcher</code> ({@link Query#CreateWeight(Searcher)}).
34 /// <li>The {@link #SumOfSquaredWeights()} method is called
35 /// on the <code>Weight</code> to compute
36 /// the query normalization factor {@link Similarity#QueryNorm(float)}
37 /// of the query clauses contained in the query.
38 /// <li>The query normalization factor is passed to {@link #Normalize(float)}.
39 /// At this point the weighting is complete.
40 /// <li>A <code>Scorer</code> is constructed by {@link #Scorer(IndexReader)}.
43 public interface Weight
45 /// <summary>The query that this concerns. </summary>
48 /// <summary>The weight for this query. </summary>
51 /// <summary>The sum of squared weights of contained query clauses. </summary>
52 float SumOfSquaredWeights();
54 /// <summary>Assigns the query normalization factor to this. </summary>
55 void Normalize(float norm
);
57 /// <summary>Constructs a scorer for this. </summary>
58 Scorer
Scorer(IndexReader reader
);
60 /// <summary>An explanation of the score computation for the named document. </summary>
61 Explanation
Explain(IndexReader reader
, int doc
);