---
title: "SKIndexGetDocumentCount(_:)"
framework: Core Services
role: symbol
role_heading: Function
platforms: [macOS 10.3+]
path: coreservices/1449093-skindexgetdocumentcount
---

# SKIndexGetDocumentCount(_:)

Gets the total number of documents represented in an index.

## Declaration

```swift
func SKIndexGetDocumentCount(_ inIndex: SKIndex!) -> CFIndex
```

## Parameters

- `inIndex`: The index whose document URL objects (of type doc://com.apple.documentation/documentation/coreservices/skdocument) you want to count.

## Return Value

Return Value A CFIndex object containing the number of document URL objects (of type SKDocument) in the index. On failure, returns 0.

## Discussion

Discussion Document URL objects (of type SKDocument)  added to an index have an indexing state of kSKDocumentStateIndexed. See the SKDocumentIndexState enumeration.  Search Kit is thread-safe. You can use separate indexing and searching threads. Your application is responsible for ensuring that no more than one process is open at a time for writing to an index. Special Considerations In the current implementation of Search Kit, SKIndexGetDocumentCount returns the number of documents represented in the on-disk index. If your application has added document URL objects to the index but has not yet called SKIndexFlush(_:), the document count may not be correct.

## See Also

### Managing Indexes

- [SKIndexAddDocumentWithText(_:_:_:_:)](coreservices/1444518-skindexadddocumentwithtext.md)
- [SKIndexAddDocument(_:_:_:_:)](coreservices/1444897-skindexadddocument.md)
- [SKIndexFlush(_:)](coreservices/1450667-skindexflush.md)
- [SKIndexCompact(_:)](coreservices/1443628-skindexcompact.md)
- [SKIndexGetMaximumDocumentID(_:)](coreservices/1444628-skindexgetmaximumdocumentid.md)
- [SKIndexGetMaximumTermID(_:)](coreservices/1444278-skindexgetmaximumtermid.md)
- [SKIndexDocumentIteratorCreate(_:_:)](coreservices/1446189-skindexdocumentiteratorcreate.md)
- [SKIndexDocumentIteratorCopyNext(_:)](coreservices/1442212-skindexdocumentiteratorcopynext.md)
- [SKIndexDocumentIteratorGetTypeID()](coreservices/1443022-skindexdocumentiteratorgettypeid.md)
- [SKIndexGetAnalysisProperties(_:)](coreservices/1443461-skindexgetanalysisproperties.md)
- [SKIndexMoveDocument(_:_:_:)](coreservices/1449899-skindexmovedocument.md)
- [SKIndexRemoveDocument(_:_:)](coreservices/1444375-skindexremovedocument.md)
- [SKIndexRenameDocument(_:_:_:)](coreservices/1448935-skindexrenamedocument.md)
- [SKIndexSetMaximumBytesBeforeFlush(_:_:)](coreservices/1448696-skindexsetmaximumbytesbeforeflus.md)
- [SKIndexGetMaximumBytesBeforeFlush(_:)](coreservices/1445329-skindexgetmaximumbytesbeforeflus.md)
