SKSearchResultsCreateWithDocuments
Finds documents similar to given example documents.
Declaration
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 Sksearchresultsfiltercallback callback function. Can be
NULL. - inFilterCallBack:
A callback function for hit testing during searching—see 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
A search results object containing a list of document URL objects (SKDocumentRefs) representing documents similar to the example documents.
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.