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.
Inheritance
Inherited Members
Namespace: Lucene.Net.Index
Assembly: Lucene.Net.dll
Syntax
public class CheckIndex
Constructors
| Improve this Doc View SourceCheckIndex(Directory)
Create a new CheckIndex on the directory.
Declaration
public CheckIndex(Directory dir)
Parameters
Type | Name | Description |
---|---|---|
Directory | dir |
Properties
| Improve this Doc View SourceCrossCheckTermVectors
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 |
---|---|
System.Boolean |
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 |
---|---|
System.IO.TextWriter |
InfoStreamIsVerbose
If true
, prints more details to the InfoStream, if set.
Declaration
public virtual bool InfoStreamIsVerbose { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceDoCheckIndex()
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 |
---|---|---|
System.Collections.Generic.IList<System.String> | onlySegments | list of specific segment names to check As this method checks every byte in the specified segments, 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. |
Returns
Type | Description |
---|---|
CheckIndex.Status |
FixIndex(CheckIndex.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()
Declaration
public virtual void FlushInfoStream()
Main(String[])
Declaration
[STAThread]
public static void Main(string[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | args |
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 | |
System.IO.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 | |
System.IO.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 | |
System.IO.TextWriter | infoStream |
Returns
Type | Description |
---|---|
CheckIndex.Status.TermIndexStatus |
TestPostings(AtomicReader, TextWriter, Boolean)
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 | |
System.IO.TextWriter | infoStream | |
System.Boolean | 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 | |
System.IO.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 | |
System.IO.TextWriter | infoStream |
Returns
Type | Description |
---|---|
CheckIndex.Status.TermVectorStatus |
TestTermVectors(AtomicReader, TextWriter, Boolean, Boolean)
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 | |
System.IO.TextWriter | infoStream | |
System.Boolean | verbose | |
System.Boolean | crossCheckTermVectors |
Returns
Type | Description |
---|---|
CheckIndex.Status.TermVectorStatus |