Package org.apache.lucene.index

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


  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, true);

    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, true);

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

                doc.add(new Field("data", data[i], Field.Store.YES, Field.Index.ANALYZED));//Field.Text("data",data[i]));
            }
            writer.addDocument(doc);
        }

        writer.optimize();
        writer.close();

        r = IndexReader.open(index, true);
        s = new IndexSearcher(r);
View Full Code Here

    for (int i = 0; i < contents.length; ++i) {
      Document doc = new Document();
      doc.add(new Field(field, contents[i], Field.Store.YES, Field.Index.ANALYZED));
      writer.addDocument(doc);
    }
    writer.optimize();
    writer.close();

    return indexStore;
  }
View Full Code Here

    for (int i = 0; i < numDocs; i++) {
      docid.setValue("" + i);
      junk.setValue(randomUnicodeString(random));
      writer.addDocument(doc);
    }
    writer.optimize();
    writer.close();
   
    IndexReader reader = IndexReader.open(dir, true);
   
    int numAsserts = 100;
View Full Code Here

        Document doc = new Document();
        doc.add (new Field ("string", "a"+i, Field.Store.NO, Field.Index.NOT_ANALYZED));
        doc.add (new Field ("string", "b"+i, Field.Store.NO, Field.Index.NOT_ANALYZED));
        writer.addDocument (doc);
    }
    writer.optimize(); // enforce one segment to have a higher unique term count in all cases
    writer.close();
    sort.setSort(new SortField[]{
        new SortField("string", SortField.STRING),
        SortField.FIELD_DOC });
    // this should not throw AIOOBE or RuntimeEx
View Full Code Here

            indexWriter = null;
        }
        // optimize if requested
        if (optimize) {
            IndexWriter writer = getIndexWriter();
            writer.optimize();
            writer.close();
            indexWriter = null;
        }
    }
View Full Code Here

        writer.setUseCompoundFile(false);

        indexDirectory(writer, dataDir);

        int numIndexed = writer.numDocs();
        writer.optimize();
        writer.close();
        return numIndexed;
    }

    /**
 
View Full Code Here

    Document document3 = new Document();
    document3.add(new Field("field", "a different sample", Field.Store.YES, Field.Index.TOKENIZED));
    document3.add(new Field("filter", "another sample filter", Field.Store.YES, Field.Index.TOKENIZED));
    document3.add(new Field("sort", "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
    writer.addDocument(document3);
    writer.optimize();
    writer.close();
  }

  /**
   * @see junit.framework.TestCase#setUp()
View Full Code Here

    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("sort", "2", Field.Store.YES, Field.Index.UN_TOKENIZED));
    writer.addDocument(document);

    writer.optimize();
   
    writer.close();
  }

  public void testDeleteOptimizeDocumentError1() throws Exception {
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.