NSMetadataQueryDidFinishGathering not being called enough

I have an app where each item in an NSTableView contains an NSMetadataQuery, to listen for updates to image files that contain the keyword associated with the item.

If I write the keywords to, RAW files, everything works as expected and the number label in the row gets updated correctly.

However, if I write the keywords to XMP sidecar files, the NSMetadataQueryDidFinishGathering callback isn't called enough times and the count of files affected isn't updated correctly.

What is more, the number returned on the final call to the callback seems to vary depending on the time of day, weather, etc

Here is the code that I have used to create the predicate for finding keywords in XMP files…

      let xmpFileTypePredicate = NSPredicate(fromMetadataQueryString: "kMDItemKind = \"XMP sidecar*\"cdwt")!

      let xmpKeywordPredicate = NSPredicate(fromMetadataQueryString: "kMDItemTextContent = \"<rdf:li>\(keyword)</rdf:li>\"cdw")!

      let xmpKeywordsMetadataQueryPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [xmpFileTypePredicate, xmpKeywordPredicate])

Can anyone give me any ideas?