public class RandomIndexWriter
extends java.lang.Object
implements java.io.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(java.util.Random r,
Directory dir)
create a RandomIndexWriter with a random config: Uses MockAnalyzer
|
RandomIndexWriter(java.util.Random r,
Directory dir,
Analyzer a)
create a RandomIndexWriter with a random config
|
RandomIndexWriter(java.util.Random r,
Directory dir,
IndexWriterConfig c)
create a RandomIndexWriter with the provided config
|
RandomIndexWriter(java.util.Random r,
Directory dir,
IndexWriterConfig c,
boolean useSoftDeletes)
create a RandomIndexWriter with the provided config
|
| Modifier and Type | Method and Description |
|---|---|
<T extends IndexableField> |
addDocument(java.lang.Iterable<T> doc)
Adds a Document.
|
long |
addDocuments(java.lang.Iterable<? extends java.lang.Iterable<? extends IndexableField>> docs) |
long |
addIndexes(CodecReader... readers) |
long |
addIndexes(Directory... dirs) |
void |
close()
Close this writer.
|
long |
commit() |
long |
deleteAll() |
long |
deleteDocuments(Query q) |
long |
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) |
IndexWriter.DocStats |
getDocStats() |
DirectoryReader |
getReader() |
DirectoryReader |
getReader(boolean applyDeletions,
boolean writeAllDeletes) |
static IndexWriter |
mockIndexWriter(Directory dir,
IndexWriterConfig conf,
java.util.Random r)
Returns an indexwriter that randomly mixes up thread scheduling (by yielding at test points)
|
static IndexWriter |
mockIndexWriter(java.util.Random r,
Directory dir,
IndexWriterConfig conf,
RandomIndexWriter.TestPoint testPoint)
Returns an indexwriter that enables the specified test point
|
void |
setDoRandomForceMerge(boolean v) |
void |
setDoRandomForceMergeAssert(boolean v) |
long |
updateBinaryDocValue(Term term,
java.lang.String field,
BytesRef value) |
<T extends IndexableField> |
updateDocument(Term t,
java.lang.Iterable<T> doc)
Updates a document.
|
long |
updateDocuments(Term delTerm,
java.lang.Iterable<? extends java.lang.Iterable<? extends IndexableField>> docs) |
long |
updateDocValues(Term term,
Field... updates) |
long |
updateNumericDocValue(Term term,
java.lang.String field,
java.lang.Long value) |
public final IndexWriter w
public RandomIndexWriter(java.util.Random r,
Directory dir)
throws java.io.IOException
java.io.IOExceptionpublic RandomIndexWriter(java.util.Random r,
Directory dir,
Analyzer a)
throws java.io.IOException
java.io.IOExceptionpublic RandomIndexWriter(java.util.Random r,
Directory dir,
IndexWriterConfig c)
throws java.io.IOException
java.io.IOExceptionpublic RandomIndexWriter(java.util.Random r,
Directory dir,
IndexWriterConfig c,
boolean useSoftDeletes)
throws java.io.IOException
java.io.IOExceptionpublic static IndexWriter mockIndexWriter(Directory dir, IndexWriterConfig conf, java.util.Random r) throws java.io.IOException
java.io.IOExceptionpublic static IndexWriter mockIndexWriter(java.util.Random r, Directory dir, IndexWriterConfig conf, RandomIndexWriter.TestPoint testPoint) throws java.io.IOException
java.io.IOExceptionpublic <T extends IndexableField> long addDocument(java.lang.Iterable<T> doc) throws java.io.IOException
java.io.IOExceptionIndexWriter.addDocument(Iterable)public long addDocuments(java.lang.Iterable<? extends java.lang.Iterable<? extends IndexableField>> docs) throws java.io.IOException
java.io.IOExceptionpublic long updateDocuments(Term delTerm, java.lang.Iterable<? extends java.lang.Iterable<? extends IndexableField>> docs) throws java.io.IOException
java.io.IOExceptionpublic <T extends IndexableField> long updateDocument(Term t, java.lang.Iterable<T> doc) throws java.io.IOException
java.io.IOExceptionIndexWriter.updateDocument(Term, Iterable)public long addIndexes(Directory... dirs) throws java.io.IOException
java.io.IOExceptionpublic long addIndexes(CodecReader... readers) throws java.io.IOException
java.io.IOExceptionpublic long updateNumericDocValue(Term term, java.lang.String field, java.lang.Long value) throws java.io.IOException
java.io.IOExceptionpublic long updateBinaryDocValue(Term term, java.lang.String field, BytesRef value) throws java.io.IOException
java.io.IOExceptionpublic long updateDocValues(Term term, Field... updates) throws java.io.IOException
java.io.IOExceptionpublic long deleteDocuments(Term term) throws java.io.IOException
java.io.IOExceptionpublic long deleteDocuments(Query q) throws java.io.IOException
java.io.IOExceptionpublic long commit()
throws java.io.IOException
java.io.IOExceptionpublic IndexWriter.DocStats getDocStats()
public long deleteAll()
throws java.io.IOException
java.io.IOExceptionpublic DirectoryReader getReader() throws java.io.IOException
java.io.IOExceptionpublic void forceMergeDeletes(boolean doWait)
throws java.io.IOException
java.io.IOExceptionpublic void forceMergeDeletes()
throws java.io.IOException
java.io.IOExceptionpublic void setDoRandomForceMerge(boolean v)
public void setDoRandomForceMergeAssert(boolean v)
public DirectoryReader getReader(boolean applyDeletions, boolean writeAllDeletes) throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionIndexWriter.close()public void forceMerge(int maxSegmentCount)
throws java.io.IOException
NOTE: this should be avoided in tests unless absolutely necessary, as it will result in less test coverage.
java.io.IOExceptionIndexWriter.forceMerge(int)public final void flush()
throws java.io.IOException
Directory.java.io.IOExceptionCopyright © 2000–2025 The Apache Software Foundation. All rights reserved.