01 /*
02 * LuceneIndexSearcher.java
03 *
04 * Niraj Aswani, 19/March/07
05 *
06 * $Id: LuceneIndexSearcher.html,v 1.0 2007/03/19 16:22:01 niraj Exp $
07 */
08 package gate.creole.annic.lucene;
09
10 import java.io.IOException;
11 import gate.creole.annic.apache.lucene.index.IndexReader;
12 import gate.creole.annic.apache.lucene.search.Filter;
13 import gate.creole.annic.apache.lucene.search.IndexSearcher;
14 import gate.creole.annic.apache.lucene.search.Query;
15 import gate.creole.annic.apache.lucene.search.TopDocs;
16 import gate.creole.annic.apache.lucene.store.Directory;
17
18 /**
19 * This class provides an implementation that searches within the lucene
20 * index to retrieve the results of a query submitted by user.
21 *
22 * @author niraj
23 *
24 */
25 public class LuceneIndexSearcher extends IndexSearcher {
26
27 /** Creates a searcher searching the index in the named directory. */
28 public LuceneIndexSearcher(String path) throws IOException {
29 super(path);
30 }
31
32 /** Creates a searcher searching the index in the provided directory. */
33 public LuceneIndexSearcher(Directory directory) throws IOException {
34 super(directory);
35 }
36
37 /** Creates a searcher searching the provided index. */
38 public LuceneIndexSearcher(IndexReader r) {
39 super(r);
40 }
41
42
43 /**
44 * Searches through the lucene index and returns an instance of TopDocs.
45 */
46 public TopDocs search(Query query, Filter filter, final int nDocs)
47 throws IOException {
48 initializeTermPositions();
49 return super.search(query, filter, nDocs);
50 }
51 }
|