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 /** Lower-level search API.
20 * @see Searcher#search(Query,HitCollector)
21 * @version $Id: HitCollector.java 529 2004-10-05 11:55:26Z niraj $
22 */
23 public abstract class HitCollector {
24 /** Called once for every non-zero scoring document, with the document number
25 * and its score.
26 *
27 * <P>If, for example, an application wished to collect all of the hits for a
28 * query in a BitSet, then it might:<pre>
29 * Searcher searcher = new IndexSearcher(indexReader);
30 * final BitSet bits = new BitSet(indexReader.maxDoc());
31 * searcher.search(query, new HitCollector() {
32 * public void collect(int doc, float score) {
33 * bits.set(doc);
34 * }
35 * });
36 * </pre>
37 *
38 * <p>Note: This is called in an inner search loop. For good search
39 * performance, implementations of this method should not call
40 * {@link Searcher#doc(int)} or
41 * {@link gate.creole.annic.apache.lucene.index.IndexReader#document(int)} on every
42 * document number encountered. Doing so can slow searches by an order
43 * of magnitude or more.
44 * <p>Note: The <code>score</code> passed to this method is a raw score.
45 * In other words, the score will not necessarily be a float whose value is
46 * between 0 and 1.
47 */
48 public abstract void collect(int doc, float score);
49 }
|