Class CheckIndex
Basic tool and API to check the health of an index and write a new segments file that removes reference to problematic segments.
As this tool checks every byte in the index, on a large index it can take quite a long time to run. Please make a complete backup of your index before using this to fix your index!Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Index
Assembly: Lucene.Net.dll
Syntax
public class CheckIndex
Constructors
CheckIndex(Directory)
Create a new CheckIndex on the directory.
Declaration
public CheckIndex(Directory dir)
Parameters
Type | Name | Description |
---|---|---|
Directory | dir |
Properties
CrossCheckTermVectors
If true
, term vectors are compared against postings to
make sure they are the same. This will likely
drastically increase time it takes to run CheckIndex!
Declaration
public virtual bool CrossCheckTermVectors { get; set; }
Property Value
Type | Description |
---|---|
bool |
InfoStream
Gets or Sets infoStream where messages should go. If null, no
messages are printed. If InfoStreamIsVerbose is true
then more
details are printed.
Declaration
public virtual TextWriter InfoStream { get; set; }
Property Value
Type | Description |
---|---|
TextWriter |
InfoStreamIsVerbose
If true
, prints more details to the InfoStream, if set.
Declaration
public virtual bool InfoStreamIsVerbose { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
DoCheckIndex()
Returns a CheckIndex.Status instance detailing the state of the index.
As this method checks every byte in the index, on a large index it can take quite a long time to run. WARNING: make sure you only call this when the index is not opened by any writer.Declaration
public virtual CheckIndex.Status DoCheckIndex()
Returns
Type | Description |
---|---|
CheckIndex.Status |
DoCheckIndex(IList<string>)
Returns a CheckIndex.Status instance detailing the state of the index.
Declaration
public virtual CheckIndex.Status DoCheckIndex(IList<string> onlySegments)
Parameters
Type | Name | Description |
---|---|---|
IList<string> | onlySegments | list of specific segment names to check
|
Returns
Type | Description |
---|---|
CheckIndex.Status |
FixIndex(Status)
Repairs the index using previously returned result from DoCheckIndex(). Note that this does not remove any of the unreferenced files after it's done; you must separately open an IndexWriter, which deletes unreferenced files when it's created.
WARNING: this writes a new segments file into the index, effectively removing all documents in broken segments from the index. BE CAREFUL. WARNING: Make sure you only call this when the index is not opened by any writer.Declaration
public virtual void FixIndex(CheckIndex.Status result)
Parameters
Type | Name | Description |
---|---|---|
CheckIndex.Status | result |
FlushInfoStream()
Basic tool and API to check the health of an index and write a new segments file that removes reference to problematic segments.
As this tool checks every byte in the index, on a large index it can take quite a long time to run. Please make a complete backup of your index before using this to fix your index!Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public virtual void FlushInfoStream()
Main(string[])
LUCENENET specific: In the Java implementation, this Main method was intended to be called from the command line. However, in .NET a method within a DLL can't be directly called from the command line so we provide a .NET tool, lucene-cli, with a command that maps to this method: index check
Declaration
[STAThread]
public static void Main(string[] args)
Parameters
Type | Name | Description |
---|---|---|
string[] | args | The command line arguments |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if invalid arguments are provided |
TestDocValues(AtomicReader, TextWriter)
Test docvalues.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public static CheckIndex.Status.DocValuesStatus TestDocValues(AtomicReader reader, TextWriter infoStream)
Parameters
Type | Name | Description |
---|---|---|
AtomicReader | reader | |
TextWriter | infoStream |
Returns
Type | Description |
---|---|
CheckIndex.Status.DocValuesStatus |
TestFieldNorms(AtomicReader, TextWriter)
Test field norms.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public static CheckIndex.Status.FieldNormStatus TestFieldNorms(AtomicReader reader, TextWriter infoStream)
Parameters
Type | Name | Description |
---|---|---|
AtomicReader | reader | |
TextWriter | infoStream |
Returns
Type | Description |
---|---|
CheckIndex.Status.FieldNormStatus |
TestPostings(AtomicReader, TextWriter)
Test the term index.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public static CheckIndex.Status.TermIndexStatus TestPostings(AtomicReader reader, TextWriter infoStream)
Parameters
Type | Name | Description |
---|---|---|
AtomicReader | reader | |
TextWriter | infoStream |
Returns
Type | Description |
---|---|
CheckIndex.Status.TermIndexStatus |
TestPostings(AtomicReader, TextWriter, bool)
Test the term index.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public static CheckIndex.Status.TermIndexStatus TestPostings(AtomicReader reader, TextWriter infoStream, bool verbose)
Parameters
Type | Name | Description |
---|---|---|
AtomicReader | reader | |
TextWriter | infoStream | |
bool | verbose |
Returns
Type | Description |
---|---|
CheckIndex.Status.TermIndexStatus |
TestStoredFields(AtomicReader, TextWriter)
Test stored fields.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public static CheckIndex.Status.StoredFieldStatus TestStoredFields(AtomicReader reader, TextWriter infoStream)
Parameters
Type | Name | Description |
---|---|---|
AtomicReader | reader | |
TextWriter | infoStream |
Returns
Type | Description |
---|---|
CheckIndex.Status.StoredFieldStatus |
TestTermVectors(AtomicReader, TextWriter)
Test term vectors.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public static CheckIndex.Status.TermVectorStatus TestTermVectors(AtomicReader reader, TextWriter infoStream)
Parameters
Type | Name | Description |
---|---|---|
AtomicReader | reader | |
TextWriter | infoStream |
Returns
Type | Description |
---|---|
CheckIndex.Status.TermVectorStatus |
TestTermVectors(AtomicReader, TextWriter, bool, bool)
Test term vectors.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public static CheckIndex.Status.TermVectorStatus TestTermVectors(AtomicReader reader, TextWriter infoStream, bool verbose, bool crossCheckTermVectors)
Parameters
Type | Name | Description |
---|---|---|
AtomicReader | reader | |
TextWriter | infoStream | |
bool | verbose | |
bool | crossCheckTermVectors |
Returns
Type | Description |
---|---|
CheckIndex.Status.TermVectorStatus |