00001
00002 package de.aitools.aq.invertedindex.usage;
00003
00004 import java.io.File;
00005 import java.io.IOException;
00006 import java.util.Scanner;
00007
00008 import de.aitools.aq.invertedindex.core.Configuration;
00009 import de.aitools.aq.invertedindex.core.Postlist;
00010 import de.aitools.aq.invertedindex.core.Searcher;
00011 import de.aitools.aq.value.single.SingleLong;
00012
00022 public class SearcherTerminal {
00023
00024 public static void main(String[] args) throws IOException {
00025
00026
00027
00028
00029 Configuration config = new Configuration();
00030 config.setIndexDirectory(new File("/path/to/your/index"));
00031
00032
00033
00034
00035 Class<SingleLong> valueClass = SingleLong.class;
00036 Searcher<SingleLong> searcher = Searcher.open(valueClass, config);
00037
00038
00039
00040
00041 Scanner scanner = new Scanner(System.in);
00042 while (true) {
00043 System.out.print("Enter key (type 'q' to exit) : ");
00044 String key = scanner.nextLine();
00045 if (key.equals("q")) break;
00046 Postlist<SingleLong> postlist = searcher.search(key);
00047 if (postlist != null) {
00048 for (SingleLong value : postlist) {
00049 value.printTo(System.out).println();
00050 }
00051 postlist.deleteNative();
00052 } else {
00053 System.out.println("Nothing found");
00054 }
00055 }
00056 searcher.close();
00057 }
00058 }