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