Lucene++ - a full-featured, c++ search engine
API Documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
Lucene::CheckIndex Class Reference

Basic tool and API to check the health of an index and write a new segments file that removes reference to problematic segments. More...

`#include <CheckIndex.h>`

Inheritance diagram for Lucene::CheckIndex:

## Public Member Functions

| CheckIndex (const DirectoryPtr &dir)
| Create a new CheckIndex on the directory. More...
virtual | ~CheckIndex ()
virtual String | getClassName ()
boost::shared_ptr< CheckIndex > | shared_from_this ()
void | setInfoStream (const InfoStreamPtr &out)
| Set infoStream where messages should go. If null, no messages are printed. More...
IndexStatusPtr | checkIndex ()
| Returns a IndexStatus instance detailing the state of the index. More...
IndexStatusPtr | checkIndex (Collection< String > onlySegments)
| Returns a IndexStatus instance detailing the state of the index. More...
void | fixIndex (const IndexStatusPtr &result)
| Repairs the index using previously returned result from checkIndex. 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. More...
Public Member Functions inherited from Lucene::LuceneObject
virtual | ~LuceneObject ()
virtual void | initialize ()
| Called directly after instantiation to create objects that depend on this object being fully constructed. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object. More...
virtual int32_t | hashCode ()
| Return hash code for this object. More...
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal. More...
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects. More...
virtual String | toString ()
| Returns a string representation of the object. More...
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock. More...
virtual LuceneSignalPtr | getSignal ()
| Return this object signal. More...
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout. More...
virtual void | unlock ()
| Unlock this object. More...
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread. More...
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout. More...
virtual void | notifyAll ()
| Notify all threads waiting for signal. More...

## Static Public Member Functions

static String | _getClassName ()
static bool | testAsserts ()
static bool | assertsOn ()
static int | main (Collection< String > args)
| Command-line interface to check and fix an index. More...

## Protected Member Functions

void | msg (const String &msg)
FieldNormStatusPtr | testFieldNorms (Collection< String > fieldNames, const SegmentReaderPtr &reader)
| Test field norms. More...
TermIndexStatusPtr | testTermIndex (const SegmentInfoPtr &info, const SegmentReaderPtr &reader)
| Test the term index. More...
StoredFieldStatusPtr | testStoredFields (const SegmentInfoPtr &info, const SegmentReaderPtr &reader)
| Test stored fields for a segment. More...
TermVectorStatusPtr | testTermVectors (const SegmentInfoPtr &info, const SegmentReaderPtr &reader)
| Test term vectors for a segment. More...
Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## Protected Attributes

InfoStreamPtr | infoStream
DirectoryPtr | dir
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Static Protected Attributes

static bool | _assertsOn

## Detailed Description

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.

WARNING: Please make a complete backup of your index before using this to fix your index!

## Constructor & Destructor Documentation

## ◆ CheckIndex()

Lucene::CheckIndex::CheckIndex | ( | const DirectoryPtr & | dir | ) |

Create a new CheckIndex on the directory.

## ◆ ~CheckIndex()

virtual Lucene::CheckIndex::~CheckIndex | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

static String Lucene::CheckIndex::_getClassName | ( |  | ) |

inline static

## ◆ assertsOn()

static bool Lucene::CheckIndex::assertsOn | ( |  | ) |

static

## ◆ checkIndex() [1/2]

IndexStatusPtr Lucene::CheckIndex::checkIndex | ( |  | ) |

Returns a IndexStatus 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.

## ◆ checkIndex() [2/2]

IndexStatusPtr Lucene::CheckIndex::checkIndex | ( | Collection< String > | onlySegments | ) |

Returns a IndexStatus instance detailing the state of the index.

Parameters

  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.

## ◆ fixIndex()

void Lucene::CheckIndex::fixIndex | ( | const IndexStatusPtr & | result | ) |

Repairs the index using previously returned result from checkIndex. 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.

## ◆ getClassName()

virtual String Lucene::CheckIndex::getClassName | ( |  | ) |

inline virtual

## ◆ main()

static int Lucene::CheckIndex::main | ( | Collection< String > | args | ) |

static

Command-line interface to check and fix an index.

Run it like this: CheckIndex pathToIndex [-fix] [-segment X] [-segment Y]

-fix: actually write a new segments_N file, removing any problematic segments

-segment X: only check the specified segment(s). This can be specified multiple times, to check more than one segment, eg -segment _2 -segment _a. You can't use this with the -fix option.

WARNING: -fix should only be used on an emergency basis as it will cause documents (perhaps many) to be permanently removed from the index. Always make a backup copy of your index before running this! Do not run this tool on an index that is actively being written to. You have been warned!

Run without -fix, this tool will open the index, report version information and report any exceptions it hits and what action it would take if -fix were specified. With -fix, this tool will remove any segments that have issues and write a new segments_N file. This means all documents contained in the affected segments will be removed.

This tool exits with exit code 1 if the index cannot be opened or has any corruption, else 0.

## ◆ msg()

void Lucene::CheckIndex::msg | ( | const String & | msg | ) |

protected

## ◆ setInfoStream()

void Lucene::CheckIndex::setInfoStream | ( | const InfoStreamPtr & | out | ) |

Set infoStream where messages should go. If null, no messages are printed.

## ◆ shared_from_this()

boost::shared_ptr< CheckIndex > Lucene::CheckIndex::shared_from_this | ( |  | ) |

inline

## ◆ testAsserts()

static bool Lucene::CheckIndex::testAsserts | ( |  | ) |

static

## ◆ testFieldNorms()

FieldNormStatusPtr Lucene::CheckIndex::testFieldNorms | ( | Collection< String > | fieldNames,
|  | const SegmentReaderPtr & | reader
| ) |  |

protected

Test field norms.

## ◆ testStoredFields()

StoredFieldStatusPtr Lucene::CheckIndex::testStoredFields | ( | const SegmentInfoPtr & | info,
|  | const SegmentReaderPtr & | reader
| ) |  |

protected

Test stored fields for a segment.

## ◆ testTermIndex()

TermIndexStatusPtr Lucene::CheckIndex::testTermIndex | ( | const SegmentInfoPtr & | info,
|  | const SegmentReaderPtr & | reader
| ) |  |

protected

Test the term index.

## ◆ testTermVectors()

TermVectorStatusPtr Lucene::CheckIndex::testTermVectors | ( | const SegmentInfoPtr & | info,
|  | const SegmentReaderPtr & | reader
| ) |  |

protected

Test term vectors for a segment.

## Field Documentation

## ◆ _assertsOn

bool Lucene::CheckIndex::_assertsOn

static protected

## ◆ dir

DirectoryPtr Lucene::CheckIndex::dir

protected

## ◆ infoStream

InfoStreamPtr Lucene::CheckIndex::infoStream

protected

The documentation for this class was generated from the following file:

- CheckIndex.h

clucene.sourceforge.net