Package org.apache.lucene.index

Examples of org.apache.lucene.index.IndexWriter.optimize()


    doc.add(new Field("time", Long.toString(System.currentTimeMillis()), Field.Store.YES, Field.Index.UN_TOKENIZED));
    doc.add(new Field("content", "��֪����ʲôʱ��ʼ����ʲô�������涼�и����ڣ��ﵶ�����ڣ����ͷ����ڣ�������ֽ������ڣ��ҿ�ʼ���ɣ�����������ϣ�����ʲô�����Dz�����ڵģ�", Field.Store.NO, Field.Index.TOKENIZED));
    IndexWriter writer = getWriter();
    try {
        writer.addDocument(doc);
        writer.optimize();
    }finally {
        writer.close();
    }
    System.out.println("doc count = " + writer.docCount());
        return 1;
View Full Code Here


    }
    //Write document
    IndexWriter writer = getWriter(doc.name());
    try {
        writer.addDocument(lucene_doc);
        writer.optimize();
    }finally {
      try{
        writer.close();
      }catch(Exception e){
        log.error("Error occur when closing IndexWriter", e);
View Full Code Here

    Directory idxDir = new RAMDirectory();
    Document[] docs = buildData();
   
    IndexWriter writer = new IndexWriter(idxDir,new StandardAnalyzer(Version.LUCENE_29),MaxFieldLength.UNLIMITED);
    writer.addDocument(docs[0]);
    writer.optimize();
    writer.commit();
   
    IndexReader idxReader = IndexReader.open(idxDir,true);
    BoboIndexReader boboReader = BoboIndexReader.getInstance(idxReader,_fconf);
View Full Code Here

      assertSame(boboReader,reader);
     
      Directory tmpDir = new RAMDirectory();
      IndexWriter subWriter = new IndexWriter(tmpDir,new StandardAnalyzer(Version.LUCENE_29),MaxFieldLength.UNLIMITED);
      subWriter.addDocument(doc);
      subWriter.optimize();
      subWriter.close();
      writer.addIndexesNoOptimize(new Directory[]{tmpDir});
      writer.commit();
      reader = (BoboIndexReader)boboReader.reopen();
      assertNotSame(boboReader, reader);
View Full Code Here

    for(long l=0; l<53; l++)
    {
      Document d = new Document();
      d.add(buildMetaField("timeinmillis", df.format(now - l*3500000)));
      writer.addDocument(d);
      writer.optimize();
      writer.commit();
    }
    IndexReader idxReader = IndexReader.open(idxDir,true);
    BoboIndexReader boboReader = BoboIndexReader.getInstance(idxReader,facetHandlers);
    BoboBrowser browser = new BoboBrowser(boboReader);
View Full Code Here

    Directory[] multiplier = new Directory[timesReplicatePerSeg];
    for (int k=0;k<timesReplicatePerSeg;++k){
      multiplier[k]=new RAMDirectory(srcDir);
    }
    subWriter.addIndexesNoOptimize(multiplier);
    subWriter.optimize();
    subWriter.close();
 
    writer.addIndexesNoOptimize(new Directory[]{ramDir});
    System.out.println("segment: "+i+" created");
  }
View Full Code Here

    oStmt.close();
    oConn.close();

    if (DebugFile.trace) DebugFile.writeln("IndexWriter.optimize()");

    oIWrt.optimize();

    if (DebugFile.trace) DebugFile.writeln("IndexWriter.close()");

    oIWrt.close();
View Full Code Here

    IndexWriter oIWrt = new IndexWriter(sDirectory, (Analyzer) oAnalyzer.newInstance(), true);

    if (DebugFile.trace) DebugFile.writeln("IndexWriter.optimize()");

    oIWrt.optimize();

    if (DebugFile.trace) DebugFile.writeln("IndexWriter.close()");

    oIWrt.close();
View Full Code Here

    oStmt.close();
    oConn.close();

    if (DebugFile.trace) DebugFile.writeln("IndexWriter.optimize()");

    oIWrt.optimize();

    if (DebugFile.trace) DebugFile.writeln("IndexWriter.close()");

    oIWrt.close();
View Full Code Here

        } catch (Exception e) {
          logger.error(e);
        } finally{
          if(writer != null){
            try{
              writer.optimize();
              writer.flush();
              writer.close();
            }catch(Exception e){
              logger.error(e);
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.