Examples of optimize()


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

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

    IndexWriter iw = new IndexWriter(dir, analyzer, MaxFieldLength.UNLIMITED);
    Document doc = new Document();
    doc.add(new Field("txt", txt, Field.Store.YES, Field.Index.ANALYZED));
    iw.addDocument(doc);
    iw.commit();
    iw.optimize();
    iw.close();
  }

  public void testSearch() {
    try {
View Full Code Here

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

        TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT)));
    Document d = new Document();
    Field f = new Field(FIELD_NAME, "multiOne", Field.Store.YES, Field.Index.ANALYZED);
    d.add(f);
    writer1.addDocument(d);
    writer1.optimize();
    writer1.close();
    IndexReader reader1 = IndexReader.open(ramDir1, true);

    // setup index 2
    Directory ramDir2 = newDirectory();
View Full Code Here

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

        TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT)));
    d = new Document();
    f = new Field(FIELD_NAME, "multiTwo", Field.Store.YES, Field.Index.ANALYZED);
    d.add(f);
    writer2.addDocument(d);
    writer2.optimize();
    writer2.close();
    IndexReader reader2 = IndexReader.open(ramDir2, true);

    IndexSearcher searchers[] = new IndexSearcher[2];
    searchers[0] = new IndexSearcher(ramDir1, true);
View Full Code Here

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

    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
    writer.addDocument( doc( "t_text1", "random words for highlighting tests del" ) );
    writer.addDocument( doc( "t_text1", "more random words for second field del" ) );
    writer.addDocument( doc( "t_text1", "random words for highlighting tests del" ) );
    writer.addDocument( doc( "t_text1", "more random words for second field" ) );
    writer.optimize();
    writer.close();
  }
 
  private void deleteDocument() throws IOException {
    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)).setOpenMode(OpenMode.APPEND));
View Full Code Here

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

    nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(7);
    doc = new Document();
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    writer.optimize();
    writer.close();
    reader = IndexReader.open(ramDir, true);
    numHighlights = 0;
  }
View Full Code Here

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

        //--------------------------------------------------------------------

        // adding one document to the empty index
        writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
        writerB.addDocument(lDoc);
        writerB.optimize();
        writerB.close();

        // building the searchables
        Searcher[] searchers2 = new Searcher[2];
        // VITAL STEP:adding the searcher for the empty index first, before the searcher for the populated index
View Full Code Here

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

        readerB.deleteDocuments(term);
        readerB.close();

        // optimizing the index with the writer
        writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
        writerB.optimize();
        writerB.close();

        // building the searchables
        Searcher[] searchers3 = new Searcher[2];
View Full Code Here

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

    Document d2 = new Document();
    d2.add(new Field("field", "a b c", Field.Store.YES, Field.Index.ANALYZED));
   
    writer.addDocument(d1);
    writer.addDocument(d2);
    writer.optimize();
    writer.close();

    Searcher searcher = new IndexSearcher(store, true);
    searcher.setSimilarity(new SimpleSimilarity());
View Full Code Here

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

    Document d1 = new Document();
    d1.add(new Field("field", "a b", Field.Store.YES, Field.Index.ANALYZED));

    writer.addDocument(d1);
    writer.optimize();
    writer.close();

    Searcher searcher = new IndexSearcher(store, true);
      QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "field", new SimpleAnalyzer());
    Query query = parser.parse("a NOT b");
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.