Exemplo n.º 1
0
  public void testApply() throws Exception {
    Central c = writeDocument(config, analyzer);

    Central newC =
        SimpleCentralConfig.createCentral(
            StorageFac.createToMongo("61.250.201.78", "search", "storageTest"));
    newC.newSearcher().search("bleujin").debugPrint();
    Debug.line('@', config.buildDir().getLockID(), newC.dir().getLockID());

    Indexer writer = c.newIndexer();
    writer.index(
        analyzer,
        new IndexJob<Void>() {
          public Void handle(IndexSession session) throws Exception {
            session.insertDocument(MyDocument.testDocument().keyword("name", "bleujin"));
            return null;
          }
        });

    newC.newSearcher().search("bleujin").debugPrint();
    Debug.line();
  }
Exemplo n.º 2
0
  private void indexSpeed(Directory dir) throws LockObtainFailedException, IOException {
    Central cram = SimpleCentralConfig.createCentral(dir);
    Indexer indexer = cram.newIndexer();

    final String readString =
        IOUtil.toString(
            new FileReader(
                new File("test/" + StringUtil.replace(this.getClass().getCanonicalName(), ".", "/"))
                    + ".java"));
    final String extString = IOUtil.toString(new FileReader(new File("build.xml")));
    indexer.index(
        new IndexJob<Void>() {

          public Void handle(IndexSession session) throws Exception {
            for (int i = 0; i < 1000; i++) {
              MyDocument doc = MyDocument.testDocument();
              doc.keyword("name", "bleujin");
              doc.text("file", extString);
              session.insertDocument(doc);
            }
            return null;
          }
        });
  }