Ejemplo n.º 1
0
 public void run() {
   try {
     for (int i = 0; i < 1024 * 8; i++) {
       searchFor(RANDOM.nextInt(), (searcher == null) ? SEARCHER : searcher);
       if (i % reopenInterval == 0) {
         if (searcher == null) {
           SEARCHER = new IndexSearcher("index");
         } else {
           searcher.close();
           searcher = new IndexSearcher("index");
         }
       }
     }
   } catch (Exception e) {
     System.out.println(e.toString());
     e.printStackTrace();
     System.exit(0);
   }
 }
Ejemplo n.º 2
0
    public void run() {
      try {
        for (int i = 0; i < 1024 * 16; i++) {
          Document d = new Document();
          int n = RANDOM.nextInt();
          d.add(Field.Keyword("id", Integer.toString(n)));
          d.add(Field.UnStored("contents", intToEnglish(n)));
          System.out.println("Adding " + n);
          writer.addDocument(d);

          if (i % reopenInterval == 0) {
            writer.close();
            writer = new IndexWriter("index", ANALYZER, false);
          }
        }
      } catch (Exception e) {
        System.out.println(e.toString());
        e.printStackTrace();
        System.exit(0);
      }
    }