'Compacts index
Used for better utilization of index metadata.
The deleted documents will be not more in structure.
:param index: the index to destroy
:type index: :py:class:`CodernityDB.index.Index`` instance, or string'

def compact_index(self, index):

    if isinstance(index, basestring):
        if (not (index in self.indexes_names)):
            raise PreconditionsException(('No    index    named    %s' % index))
        index = self.indexes_names[index]
    elif (not (index in self.indexes)):
        self.__not_opened()
        raise PreconditionsException('Argument    must    be    Index    instance    or    valid    string    index    format')
    if getattr(index, 'compacting', False):
        raise ReindexException(('The    index=%s    is    still    compacting' % index.name))
    index.compacting = True
    index.compact()
    del index.compacting
