Function

SKIndexCompact(_:)

Invokes all pending updates associated with an index, compacts the index if compaction is needed, and commits all changes to backing store.

Declaration

func SKIndexCompact(_ inIndex: SKIndex!) -> Bool

Parameters

inIndex

The index you want to compact.

Return Value

A Boolean value of true on success, or false on failure.

Discussion

Over time, as document URL objects (of type SKDocument) and associated contents get added to and removed from an index, the index’s disk or memory footprint may grow due to fragmentation.

Compacting can take a significant amount of time. Do not call SKIndexCompact(_:) on the main thread in an application with a user interface. Call it only if the index is significantly fragmented and according to the needs of your application.

Calling SKIndexCompact(_:) changes the block allocation for an index’s backing store. Close all clients of an index before calling this function.

See Also

Managing Indexes

func SKIndexAddDocumentWithText(SKIndex!, SKDocument!, CFString!, Bool)

Adds a document URL (SKDocument) object, and the associated document’s textual content, to an index.

func SKIndexAddDocument(SKIndex!, SKDocument!, CFString!, Bool)

Adds location information for a file-based document, and the document’s textual content, to an index.

func SKIndexFlush(SKIndex!)

Invokes all pending updates associated with an index and commits them to backing store.

func SKIndexGetDocumentCount(SKIndex!)

Gets the total number of documents represented in an index.

func SKIndexGetMaximumDocumentID(SKIndex!)

Gets the highest-numbered document ID in an index.

func SKIndexGetMaximumTermID(SKIndex!)

Gets the highest-numbered term ID in an index.

func SKIndexDocumentIteratorCreate(SKIndex!, SKDocument!)

Creates an index-based iterator for document URL objects (of type SKDocument) owned by a parent document URL object.

func SKIndexDocumentIteratorCopyNext(SKIndexDocumentIterator!)

Obtains the next document URL object (of type SKDocument) from an index using a document iterator.

func SKIndexDocumentIteratorGetTypeID()

Gets the type identifier for Search Kit document iterators.

func SKIndexGetAnalysisProperties(SKIndex!)

Gets the text analysis properties of an index.

func SKIndexMoveDocument(SKIndex!, SKDocument!, SKDocument!)

Changes the parent of a document URL object (of type SKDocument) in an index.

func SKIndexRemoveDocument(SKIndex!, SKDocument!)

Removes a document URL object (of type SKDocument) and its children, if any, from an index.

func SKIndexRenameDocument(SKIndex!, SKDocument!, CFString!)

Changes the name of a document URL object (of type SKDocument) in an index.

func SKIndexSetMaximumBytesBeforeFlush(SKIndex!, CFIndex)

Not recommended. Sets the memory size limit for updates to an index, measured in bytes.

func SKIndexGetMaximumBytesBeforeFlush(SKIndex!)

Not recommended. Gets the memory size limit for updates to an index, measured in bytes.