Package org.apache.lucene.index

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


    IndexWriter writer = new IndexWriter(ramDir, new StandardAnalyzer(), true);
    for (int i = 0; i < texts.length; i++) {
      addDoc(writer, texts[i]);
    }

    writer.optimize();
    writer.close();
    reader = IndexReader.open(ramDir);
    numHighlights = 0;
  }
View Full Code Here


    addDoc("aaabb", writer);
    addDoc("aabbb", writer);
    addDoc("abbbb", writer);
    addDoc("bbbbb", writer);
    addDoc("ddddd", writer);
    writer.optimize();
    writer.close();
    IndexSearcher searcher = new IndexSearcher(directory);

    FuzzyQuery query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 0);  
    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
View Full Code Here

  public void testFuzzinessLong() throws Exception {
    RAMDirectory directory = new RAMDirectory();
    IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
    addDoc("aaaaaaa", writer);
    addDoc("segment", writer);
    writer.optimize();
    writer.close();
    IndexSearcher searcher = new IndexSearcher(directory);

    FuzzyQuery query;
    // not similar enough:
View Full Code Here

    RAMDirectory directory = new RAMDirectory();
    IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(),
        true, IndexWriter.MaxFieldLength.LIMITED);
    addDoc("12345678911", writer);
    addDoc("segment", writer);
    writer.optimize();
    writer.close();
    IndexSearcher searcher = new IndexSearcher(directory);

    Query query;
    // term not over 10 chars, so optimization shortcuts
View Full Code Here

    for (int i = 0; i < 1000; i++) {
      Document doc = new Document();
      doc.add(new Field("field", English.intToEnglish(i), Field.Store.YES, Field.Index.ANALYZED));
      writer.addDocument(doc);
    }
    writer.optimize();
    writer.close();

    searcher = new IndexSearcher(directory, true);
    searcher.setSimilarity(similarity);
  }
View Full Code Here

 
  public void testRAMDirectorySize() throws IOException, InterruptedException {
     
    final MockRAMDirectory ramDir = new MockRAMDirectory(indexDir.getCanonicalPath());
    final IndexWriter writer  = new IndexWriter(ramDir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
    writer.optimize();
   
    assertEquals(ramDir.sizeInBytes(), ramDir.getRecomputedSizeInBytes());
   
    Thread[] threads = new Thread[numThreads];
    for (int i=0; i<numThreads; i++) {
View Full Code Here

    for (int i=0; i<numThreads; i++)
      threads[i].start();
    for (int i=0; i<numThreads; i++)
      threads[i].join();

    writer.optimize();
    assertEquals(ramDir.sizeInBytes(), ramDir.getRecomputedSizeInBytes());
   
    writer.close();
  }
View Full Code Here

    IndexWriter writer = new IndexWriter(store, analyzer, true,
                                         IndexWriter.MaxFieldLength.LIMITED);
    Document d = new Document();
    d.add(new Field("field", "bogus", Field.Store.YES, Field.Index.ANALYZED));
    writer.addDocument(d);
    writer.optimize();
    writer.close();
   

    IndexSearcher searcher = new IndexSearcher(store);
   
View Full Code Here

          //System.out.println(d);
        }
      }
      iw.addDocument(d);
    }
    iw.optimize();
    iw.close();
  }


  public BitSet randBitSet(int sz, int numBitsToSet) {
View Full Code Here

    final MockDirectoryWrapper ramDir = new MockDirectoryWrapper(random, new RAMDirectory(dir));
    dir.close();
   
    final IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig(
        TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
    writer.optimize();
   
    assertEquals(ramDir.sizeInBytes(), ramDir.getRecomputedSizeInBytes());
   
    Thread[] threads = new Thread[numThreads];
    for (int i=0; i<numThreads; i++) {
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.