Example usage for org.apache.lucene.index RandomIndexWriter flush

List of usage examples for org.apache.lucene.index RandomIndexWriter flush

Introduction

In this page you can find the example usage for org.apache.lucene.index RandomIndexWriter flush.

Prototype

public final void flush() throws IOException 

Source Link

Document

Writes all in-memory segments to the Directory .

Usage

From source file:org.elasticsearch.search.SearchCancellationTests.java

License:Apache License

@BeforeClass
public static void setup() throws IOException {
    dir = newDirectory();/*w  ww .j  av  a 2 s.co  m*/
    RandomIndexWriter w = new RandomIndexWriter(random(), dir);
    // we need at least 2 segments - so no merges should be allowed
    w.w.getConfig().setMergePolicy(NoMergePolicy.INSTANCE);
    w.setDoRandomForceMerge(false);
    indexRandomDocuments(w, TestUtil.nextInt(random(), 2, 20));
    w.flush();
    indexRandomDocuments(w, TestUtil.nextInt(random(), 1, 20));
    reader = w.getReader();
    w.close();
}