2006-09-10 Francisco Javier F. Serrador <serrador@openshine.com>
[beagle.git] / beagled / Lucene.Net / Search / Weight.cs
bloba4924845b1da2d7b3bfd6a02d4b77db8b10e096d
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 using IndexReader = Lucene.Net.Index.IndexReader;
18 namespace Lucene.Net.Search
21 /// <summary>Expert: Calculate query weights and build query scorers.
22 /// <p>
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.
27 /// <p>
28 /// A <code>Weight</code> is used in the following way:
29 /// <ol>
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)}.
39 /// </ol>
40 /// </summary>
41 public interface Weight
43 /// <summary>The query that this concerns. </summary>
44 Query GetQuery();
46 /// <summary>The weight for this query. </summary>
47 float GetValue();
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);