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
|
RandomIndexWriter(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(Iterable<T> doc)
Adds a Document.
|
long |
addDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs) |
long |
addIndexes(CodecReader... readers) |
long |
addIndexes(Directory... dirs) |
void |
close()
Close this writer.
|
long |
commit() |
long |
commit(boolean flushConcurrently) |
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,
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
|
void |
setDoRandomForceMerge(boolean v) |
void |
setDoRandomForceMergeAssert(boolean v) |
long |
updateBinaryDocValue(Term term,
String field,
BytesRef value) |
<T extends IndexableField> |
updateDocument(Term t,
Iterable<T> doc)
Updates a document.
|
long |
updateDocuments(Term delTerm,
Iterable<? extends Iterable<? extends IndexableField>> docs) |
long |
updateDocValues(Term term,
Field... updates) |
long |
updateNumericDocValue(Term term,
String field,
Long value) |
public final IndexWriter w
public RandomIndexWriter(Random r, Directory dir) throws IOException
IOException
public RandomIndexWriter(Random r, Directory dir, Analyzer a) throws IOException
IOException
public RandomIndexWriter(Random r, Directory dir, IndexWriterConfig c) throws IOException
IOException
public RandomIndexWriter(Random r, Directory dir, IndexWriterConfig c, boolean useSoftDeletes) throws IOException
IOException
public static IndexWriter mockIndexWriter(Directory dir, IndexWriterConfig conf, Random r) throws IOException
IOException
public static IndexWriter mockIndexWriter(Random r, Directory dir, IndexWriterConfig conf, RandomIndexWriter.TestPoint testPoint) throws IOException
IOException
public <T extends IndexableField> long addDocument(Iterable<T> doc) throws IOException
IOException
IndexWriter.addDocument(Iterable)
public long addDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs) throws IOException
IOException
public long updateDocuments(Term delTerm, Iterable<? extends Iterable<? extends IndexableField>> docs) throws IOException
IOException
public <T extends IndexableField> long updateDocument(Term t, Iterable<T> doc) throws IOException
IOException
IndexWriter.updateDocument(Term, Iterable)
public long addIndexes(Directory... dirs) throws IOException
IOException
public long addIndexes(CodecReader... readers) throws IOException
IOException
public long updateNumericDocValue(Term term, String field, Long value) throws IOException
IOException
public long updateBinaryDocValue(Term term, String field, BytesRef value) throws IOException
IOException
public long updateDocValues(Term term, Field... updates) throws IOException
IOException
public long deleteDocuments(Term term) throws IOException
IOException
public long deleteDocuments(Query q) throws IOException
IOException
public long commit() throws IOException
IOException
public long commit(boolean flushConcurrently) throws IOException
IOException
public IndexWriter.DocStats getDocStats()
public long deleteAll() throws IOException
IOException
public DirectoryReader getReader() throws IOException
IOException
public void forceMergeDeletes(boolean doWait) throws IOException
IOException
public void forceMergeDeletes() throws IOException
IOException
public void setDoRandomForceMerge(boolean v)
public void setDoRandomForceMergeAssert(boolean v)
public DirectoryReader getReader(boolean applyDeletions, boolean writeAllDeletes) throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
IndexWriter.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.
IOException
IndexWriter.forceMerge(int)
public final void flush() throws IOException
Directory
.IOException
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.