I just adding a way to donate my app's data to Core Spotlight using CSSearchableIndex
, but I'm finding that spotlight is only searching for the title
of the CSSearchableItem
I create. I know the index is working, because it always finds the item through the title
property, but nothing else.
This is how I'm creating the CSSearchableItem:
- (CSSearchableItem *) createSearchableItem {
CSSearchableItemAttributeSet* attributeSet = [[CSSearchableItemAttributeSet alloc] initWithContentType: UTTypeText];
attributeSet.title = [self titleForIndex];
attributeSet.displayName = [self titleForIndex];
attributeSet.contentDescription = [self contentDescriptionForIndex];
attributeSet.thumbnailData = [self thumbnailDataForIndex];
attributeSet.textContent = [self contentDescriptionForIndex];
CSSearchableItem *item = [[CSSearchableItem alloc] initWithUniqueIdentifier: [self referenceURLString] domainIdentifier:@"com.cjournal.cjournal-Logs" attributeSet:attributeSet];
item.expirationDate = [NSDate distantFuture];
return item;
}
There's a lot of confusing tips around which say specifying the 'textContent' should work, and/or setting the displayName
is essential, but none of these are working.
Is there something I'm missing with my setup? Thanks.