Custom attribute for CSSearchableItemAttributeSet seems not working

In the document it says you can define your own custom attribute:

The attributes you choose depend on your domain. You can use the properties that Core Spotlight provides in categories that CSSearchableItemAttributeSet defines (such as Media and Documents), or you can define your own. If you want to define a custom attribute, be as specific as possible in your definition and use the contentTypeTree property so that your custom attribute can inherit from a known type.

I tried to index a custom attribute with the following code:

class mySpotlightDelegate:NSCoreDataCoreSpotlightDelegate {
    static let myCustomAttr = CSCustomAttributeKey(keyName: "myCustomAttr")!
    override func attributeSet(for object: NSManagedObject) -> CSSearchableItemAttributeSet? {
        if let myObject = object as? MyObject {
            let attributeSet = CSSearchableItemAttributeSet(contentType: .bookmark)
            attributeSet.title = myObject.name
            attributeSet.setValue(
                NSString(string: myObject.myAttr),
                forCustomKey: mySpotlightDelegate.myCustomAttr
            )
            return attributeSet
        }
        return nil
    }
}

But later I couldn't either search with the custom attribute nor get the value of that custom attribute in the CSSearchQuery foundItemsHandler. (The search returns nil and when searched with title it was fine, but when I tried to get the value of custom attribute of returned items with item.attributeSet.value(forCustomKey: mySpotlightDelegate.myCustomAttr), the value is always nil)

I've read through all official document regarding this and also searched everywhere but can't find an example of this anywhere, execept 2 other developers complaining about this problem.

Is this a bug, or I'm doing it wrong? What's the right way to do it?

Custom attribute for CSSearchableItemAttributeSet seems not working
 
 
Q