public class RandomIndexWriter extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
static interface |
RandomIndexWriter.TestPoint
Simple interface that is executed for each TP
InfoStream component
message. |
| Modifier and Type | Field and Description |
|---|---|
IndexWriter |
w |
| Constructor and Description |
|---|
RandomIndexWriter(Random r,
Directory dir)
create a RandomIndexWriter with a random config: Uses MockAnalyzer
|
RandomIndexWriter(Random r,
Directory dir,
Analyzer a)
create a RandomIndexWriter with a random config
|
RandomIndexWriter(Random r,
Directory dir,
IndexWriterConfig c)
create a RandomIndexWriter with the provided config
|
| Modifier and Type | Method and Description |
|---|---|
<T extends IndexableField> |
addDocument(Iterable<T> doc)
Adds a Document.
|
void |
addDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs) |
void |
addIndexes(CodecReader... readers) |
void |
addIndexes(Directory... dirs) |
void |
close()
Close this writer.
|
void |
commit() |
void |
deleteAll() |
void |
deleteDocuments(Query q) |
void |
deleteDocuments(Term term) |
void |
flush()
Writes all in-memory segments to the
Directory. |
void |
forceMerge(int maxSegmentCount)
Forces a forceMerge.
|
void |
forceMergeDeletes() |
void |
forceMergeDeletes(boolean doWait) |
DirectoryReader |
getReader() |
DirectoryReader |
getReader(boolean applyDeletions) |
int |
maxDoc() |
static IndexWriter |
mockIndexWriter(Directory dir,
IndexWriterConfig conf,
Random r)
Returns an indexwriter that randomly mixes up thread scheduling (by yielding at test points)
|
static IndexWriter |
mockIndexWriter(Random r,
Directory dir,
IndexWriterConfig conf,
RandomIndexWriter.TestPoint testPoint)
Returns an indexwriter that enables the specified test point
|
int |
numDocs() |
void |
setDoRandomForceMerge(boolean v) |
void |
setDoRandomForceMergeAssert(boolean v) |
void |
updateBinaryDocValue(Term term,
String field,
BytesRef value) |
<T extends IndexableField> |
updateDocument(Term t,
Iterable<T> doc)
Updates a document.
|
void |
updateDocuments(Term delTerm,
Iterable<? extends Iterable<? extends IndexableField>> docs) |
void |
updateDocValues(Term term,
Field... updates) |
void |
updateNumericDocValue(Term term,
String field,
Long value) |
public IndexWriter w
public RandomIndexWriter(Random r, Directory dir) throws IOException
IOExceptionpublic RandomIndexWriter(Random r, Directory dir, Analyzer a) throws IOException
IOExceptionpublic RandomIndexWriter(Random r, Directory dir, IndexWriterConfig c) throws IOException
IOExceptionpublic static IndexWriter mockIndexWriter(Directory dir, IndexWriterConfig conf, Random r) throws IOException
IOExceptionpublic static IndexWriter mockIndexWriter(Random r, Directory dir, IndexWriterConfig conf, RandomIndexWriter.TestPoint testPoint) throws IOException
IOExceptionpublic <T extends IndexableField> void addDocument(Iterable<T> doc) throws IOException
IOExceptionIndexWriter.addDocument(Iterable)public void addDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs) throws IOException
IOExceptionpublic void updateDocuments(Term delTerm, Iterable<? extends Iterable<? extends IndexableField>> docs) throws IOException
IOExceptionpublic <T extends IndexableField> void updateDocument(Term t, Iterable<T> doc) throws IOException
IOExceptionIndexWriter.updateDocument(Term, Iterable)public void addIndexes(Directory... dirs) throws IOException
IOExceptionpublic void addIndexes(CodecReader... readers) throws IOException
IOExceptionpublic void updateNumericDocValue(Term term, String field, Long value) throws IOException
IOExceptionpublic void updateBinaryDocValue(Term term, String field, BytesRef value) throws IOException
IOExceptionpublic void updateDocValues(Term term, Field... updates) throws IOException
IOExceptionpublic void deleteDocuments(Term term) throws IOException
IOExceptionpublic void deleteDocuments(Query q) throws IOException
IOExceptionpublic void commit()
throws IOException
IOExceptionpublic int numDocs()
public int maxDoc()
public void deleteAll()
throws IOException
IOExceptionpublic DirectoryReader getReader() throws IOException
IOExceptionpublic void forceMergeDeletes(boolean doWait)
throws IOException
IOExceptionpublic void forceMergeDeletes()
throws IOException
IOExceptionpublic void setDoRandomForceMerge(boolean v)
public void setDoRandomForceMergeAssert(boolean v)
public DirectoryReader getReader(boolean applyDeletions) throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionIndexWriter.close()public void forceMerge(int maxSegmentCount)
throws IOException
NOTE: this should be avoided in tests unless absolutely necessary, as it will result in less test coverage.
IOExceptionIndexWriter.forceMerge(int)public final void flush()
throws IOException
Directory.IOExceptionCopyright © 2000-2016 Apache Software Foundation. All Rights Reserved.