I'm having some difficulty getting items added to the search index using the item batching. With the same NSArray (items) of CSSearchableItem objects, the following code:
[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:items
completionHandler: ^(NSError * __nullable error)
{
if (error)
NSLog(@"Error indexing items.");
else
NSLog(@"Items indexed.");
}
];works fine and properly adds all the objects in the items array to the search index.
But substituting this code:
CSSearchableIndex *index = [CSSearchableIndex new];
[index beginIndexBatch];
[index indexSearchableItems:items completionHandler:nil];
[index endIndexBatchWithClientState:clientState completionHandler:^(NSError *error)
{
NSLog(@"Item Batching: %@", error.description);
}
];results in no errors in the log (error.description is null) but the items I tried to index do not show up in any searches using Spotlight.
I'm not sure what, if anything, I'm doing wrong. I'm fairly new to xcode/objective c/foundation so if there's anything that I should be doing that might seem obvious to most, let me know. Any help is appreciated and if anyone has actually managed to get the index batching to work, I'd love to hear about it.
- Dave W