Problem
How can I search an index via API?
Solution
import org.egothor.dir.TankerImpl;
import org.egothor.query.Executor;
import org.egothor.data.*;
public class Search {
public static void main(String[] args) throws Exception {
TankerImpl index = new TankerImpl("index/",false,32,10);
QueryResponse qr = Executor.query(
0, // hits starting at this offset position
10, // number of hits to get
1, // 1 = vector model, >10 boolean model, else fuzzy model
"is", // query
index);
System.out.println("Hits total "+qr.getWouldBe()+
", returned "+qr.getEnumerationLength());
java.util.Enumeration e = qr.getEnumeration();
while (e.hasMoreElements()) {
System.out.println(e.nextElement().toString());
}
index.close();
}
}
See:
IndexingAPI
--
LeoGalambos - 15 Mar 2004