KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lucene > search > Weight


1 package org.apache.lucene.search;
2
3 /**
4  * Copyright 2004 The Apache Software Foundation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.io.IOException JavaDoc;
20
21 import org.apache.lucene.index.IndexReader;
22
23 /** Expert: Calculate query weights and build query scorers.
24  * <p>
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.
29  * <p>
30  * A <code>Weight</code> is used in the following way:
31  * <ol>
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)}.
41  * </ol>
42  */

43 public interface Weight extends java.io.Serializable JavaDoc {
44   /** The query that this concerns. */
45   Query getQuery();
46
47   /** The weight for this query. */
48   float getValue();
49
50   /** The sum of squared weights of contained query clauses. */
51   float sumOfSquaredWeights() throws IOException JavaDoc;
52
53   /** Assigns the query normalization factor to this. */
54   void normalize(float norm);
55
56   /** Constructs a scorer for this. */
57   Scorer scorer(IndexReader reader) throws IOException JavaDoc;
58
59   /** An explanation of the score computation for the named document. */
60   Explanation explain(IndexReader reader, int doc) throws IOException JavaDoc;
61 }
62
Popular Tags