---
title: SKSearchResultsCreateWithDocuments
framework: Core Services
role: symbol
role_heading: Function
platforms: [macOS 10.3+]
path: coreservices/1448629-sksearchresultscreatewithdocumen
---

# SKSearchResultsCreateWithDocuments

Finds documents similar to given example documents.

## Declaration

```occ
SKSearchResultsRef SKSearchResultsCreateWithDocuments(SKSearchGroupRef inSearchGroup, CFArrayRef inExampleDocuments, CFIndex inMaxFoundDocuments, void *inContext, SKSearchResultsFilterCallBack inFilterCallBack);
```

## Parameters

- `inSearchGroup`: A search group containing the indexes which, in turn, contain the document URL objects (SKDocumentRefs) representing the documents you want to search by similarity. The search group must also contains the indexes that contain the textual content of the example documents.
- `inExampleDocuments`: An array of document URL objects (SKDocumentRefs), each representing an example document.
- `inMaxFoundDocuments`: The maximum number of found items to return. Your application must pass in a positive value.
- `inContext`: An application-specified context for use by the doc://com.apple.documentation/documentation/coreservices/sksearchresultsfiltercallback callback function. Can be NULL.
- `inFilterCallBack`: A callback function for hit testing during searching—see doc://com.apple.documentation/documentation/coreservices/sksearchresultsfiltercallback. In a similarity search, your application would typically use this function to exclude the example documents from the search results. This parameter can be NULL, in which case your application receives the returned results directly and without any custom postprocessing.

## Return Value

Return Value A search results object containing a list of document URL objects (SKDocumentRefs) representing documents similar to the example documents.

## Discussion

Discussion This function searches the on-disk indexes in a search group for document URL objects (SKDocumentRefs) representing documents similar to those provided as examples. Build the search group in three steps: Collect the index IDs from the search groups you want to search: for each search group, call the SKSearchGroupCopyIndexes function. Add the document URL objects representing the example documents to a memory-based index (if they’re not already in an index) by calling SKIndexCreateWithMutableData, and get that index’s ID. Create a new search group that contains the indexes to search, and also containing the example-documents index, using SKSearchGroupCreate. Before invoking a search, call SKIndexFlush on all indexes in the search group to ensure that changes to the indexes have been written to disk. Once you’ve obtained the results of a search, get the specifics—including which documents match the user’s similarity query, and the ranking scores for each document—by calling SKSearchResultsGetInfoInRange. When your application no longer needs the search result, dispose of it by calling CFRelease.

## See Also

### Legacy Support for Synchronous Searching

- [SKSearchGroupCreate](coreservices/1448627-sksearchgroupcreate.md)
- [SKSearchGroupCopyIndexes](coreservices/1448615-sksearchgroupcopyindexes.md)
- [SKSearchGroupGetTypeID](coreservices/1448637-sksearchgroupgettypeid.md)
- [SKSearchResultsGetInfoInRange](coreservices/1448618-sksearchresultsgetinfoinrange.md)
- [SKSearchResultsCopyMatchingTerms](coreservices/1448612-sksearchresultscopymatchingterms.md)
- [SKSearchResultsGetCount](coreservices/1448598-sksearchresultsgetcount.md)
- [SKSearchResultsGetTypeID](coreservices/1448603-sksearchresultsgettypeid.md)
- [SKSearchResultsCreateWithQuery](coreservices/1448610-sksearchresultscreatewithquery.md)
