|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Searchable | Line # 35 | 0 | 0 | - |
-1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| No Tests | |||
| 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 org.apache.lucene.document.Document; | |
| 20 | import org.apache.lucene.index.IndexReader; | |
| 21 | import org.apache.lucene.index.Term; | |
| 22 | ||
| 23 | import java.io.IOException; // for javadoc | |
| 24 | ||
| 25 | /** The interface for search implementations. | |
| 26 | * | |
| 27 | * <p>Searchable is the abstract network protocol for searching. | |
| 28 | * Implementations provide search over a single index, over multiple | |
| 29 | * indices, and over indices on remote servers. | |
| 30 | * | |
| 31 | * <p>Queries, filters and sort criteria are designed to be compact so that | |
| 32 | * they may be efficiently passed to a remote index, with only the top-scoring | |
| 33 | * hits being returned, rather than every non-zero scoring hit. | |
| 34 | */ | |
| 35 | public interface Searchable extends java.rmi.Remote { | |
| 36 | /** Lower-level search API. | |
| 37 | * | |
| 38 | * <p>{@link HitCollector#collect(int,float)} is called for every non-zero | |
| 39 | * scoring document. | |
| 40 | * <br>HitCollector-based access to remote indexes is discouraged. | |
| 41 | * | |
| 42 | * <p>Applications should only use this if they need <i>all</i> of the | |
| 43 | * matching documents. The high-level search API ({@link | |
| 44 | * Searcher#search(Query)}) is usually more efficient, as it skips | |
| 45 | * non-high-scoring hits. | |
| 46 | * | |
| 47 | * @param weight to match documents | |
| 48 | * @param filter if non-null, a bitset used to eliminate some documents | |
| 49 | * @param results to receive hits | |
| 50 | * @throws BooleanQuery.TooManyClauses | |
| 51 | */ | |
| 52 | void search(Weight weight, Filter filter, HitCollector results) | |
| 53 | throws IOException; | |
| 54 | ||
| 55 | ||
| 56 | /** Frees resources associated with this Searcher. | |
| 57 | * Be careful not to call this method while you are still using objects | |
| 58 | * like {@link Hits}. | |
| 59 | */ | |
| 60 | void close() throws IOException; | |
| 61 | ||
| 62 | /** Expert: Returns the number of documents containing <code>term</code>. | |
| 63 | * Called by search code to compute term weights. | |
| 64 | * @see IndexReader#docFreq(Term) | |
| 65 | */ | |
| 66 | int docFreq(Term term) throws IOException; | |
| 67 | ||
| 68 | /** Expert: For each term in the terms array, calculates the number of | |
| 69 | * documents containing <code>term</code>. Returns an array with these | |
| 70 | * document frequencies. Used to minimize number of remote calls. | |
| 71 | */ | |
| 72 | int[] docFreqs(Term[] terms) throws IOException; | |
| 73 | ||
| 74 | /** Expert: Returns one greater than the largest possible document number. | |
| 75 | * Called by search code to compute term weights. | |
| 76 | * @see IndexReader#maxDoc() | |
| 77 | */ | |
| 78 | int maxDoc() throws IOException; | |
| 79 | ||
| 80 | /** Expert: Low-level search implementation. Finds the top <code>n</code> | |
| 81 | * hits for <code>query</code>, applying <code>filter</code> if non-null. | |
| 82 | * | |
| 83 | * <p>Called by {@link Hits}. | |
| 84 | * | |
| 85 | * <p>Applications should usually call {@link Searcher#search(Query)} or | |
| 86 | * {@link Searcher#search(Query,Filter)} instead. | |
| 87 | * @throws BooleanQuery.TooManyClauses | |
| 88 | */ | |
| 89 | TopDocs search(Weight weight, Filter filter, int n) throws IOException; | |
| 90 | ||
| 91 | /** Expert: Returns the stored fields of document <code>i</code>. | |
| 92 | * Called by {@link HitCollector} implementations. | |
| 93 | * @see IndexReader#document(int) | |
| 94 | */ | |
| 95 | Document doc(int i) throws IOException; | |
| 96 | ||
| 97 | /** Expert: called to re-write queries into primitive queries. | |
| 98 | * @throws BooleanQuery.TooManyClauses | |
| 99 | */ | |
| 100 | Query rewrite(Query query) throws IOException; | |
| 101 | ||
| 102 | /** Expert: low-level implementation method | |
| 103 | * Returns an Explanation that describes how <code>doc</code> scored against | |
| 104 | * <code>weight</code>. | |
| 105 | * | |
| 106 | * <p>This is intended to be used in developing Similarity implementations, | |
| 107 | * and, for good performance, should not be displayed with every hit. | |
| 108 | * Computing an explanation is as expensive as executing the query over the | |
| 109 | * entire index. | |
| 110 | * <p>Applications should call {@link Searcher#explain(Query, int)}. | |
| 111 | * @throws BooleanQuery.TooManyClauses | |
| 112 | */ | |
| 113 | Explanation explain(Weight weight, int doc) throws IOException; | |
| 114 | ||
| 115 | /** Expert: Low-level search implementation with arbitrary sorting. Finds | |
| 116 | * the top <code>n</code> hits for <code>query</code>, applying | |
| 117 | * <code>filter</code> if non-null, and sorting the hits by the criteria in | |
| 118 | * <code>sort</code>. | |
| 119 | * | |
| 120 | * <p>Applications should usually call {@link | |
| 121 | * Searcher#search(Query,Filter,Sort)} instead. | |
| 122 | * @throws BooleanQuery.TooManyClauses | |
| 123 | */ | |
| 124 | TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort) | |
| 125 | throws IOException; | |
| 126 | ||
| 127 | } | |
|
||||||||||