I have already restricted the searchScope to the directory with the notes in them.
Today I was experimenting with Spotlight again (is there really good documentation for it out there?).
When I add the type of the data I am expecting (plain text), the search gets real quick - exactly as expected. So the code now looks like this:
// Predicate expression for the search string
NSString *predicateFormat = @"kMDItemTextContent like[cd] %@";
// Predicate expression for
NSString *textType = @"kMDItemContentType == 'public.plain-text'";
// If there is something to search for ..
if (_searchKey != nil )
// Create the predicate for the key
NSPredicate *p = [NSPredicate predicateWithFormat:predicateFormat,
// And one for the type
NSPredicate * subPredicate = [NSPredicate predicateWithFormat:
// Combine the two
p = [NSCompoundPredicate andPredicateWithSubpredicates:
[NSArray arrayWithObjects:p, subPredicate, nil]];
// And set on the query
This simple addition of kMDItemContentType == 'public.plain-text' provides the speedup.
It is unfortunately not clear to me why, as I don't have any other files of other types in the searchScope.
Next thing for me to investigate is not why this spinning thingy (they are called async arrows :) does not stop spinning when spotlight does no longer return results. Perhaps I need to programatically set this and can't rely on the cocoa bindings here - does anyone know?