01 package gate.creole.annic.apache.lucene.search;
02
03 /**
04 * Copyright 2004 The Apache Software Foundation
05 *
06 * Licensed under the Apache License, Version 2.0 (the "License");
07 * you may not use this file except in compliance with the License.
08 * You may obtain a copy of the License at
09 *
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;
20
21 import gate.creole.annic.apache.lucene.index.IndexReader;
22
23 /** Expert: Calculate query weights and build query scorers.
24 *
25 * <p>A Weight is constructed by a query, given a Searcher ({@link
26 * Query#createWeight(Searcher)}). The {@link #sumOfSquaredWeights()} method
27 * is then called on the top-level query to compute the query normalization
28 * factor (@link Similarity#queryNorm(float)}). This factor is then passed to
29 * {@link #normalize(float)}. At this point the weighting is complete and a
30 * scorer may be constructed by calling {@link #scorer(IndexReader)}.
31 */
32 public interface Weight extends java.io.Serializable {
33
34 /** The query that this concerns. */
35 Query getQuery();
36
37 /** The weight for this query. */
38 float getValue();
39
40 /** The sum of squared weights of contained query clauses. */
41 float sumOfSquaredWeights() throws IOException;
42
43 /** Assigns the query normalization factor to this. */
44 void normalize(float norm);
45
46 /** Constructs a scorer for this. */
47 Scorer scorer(IndexReader reader, Searcher searcher) throws IOException;
48
49 /** An explanation of the score computation for the named document. */
50 Explanation explain(IndexReader reader, int doc) throws IOException;
51 }
|