1

I want to add the ability to search for conversations/messages in LayerKit by message text content. Is this possible? I'd assume I'd need to query on the LYRMessagePart of the LYRMessage in some fashion, but I'm having no luck.

Something like so seems like it should be doable:

let messageTextQuery = LYRQuery(queryableClass: LYRMessage.self)
messageTextQuery.predicate = LYRPredicate(property: "parts.text", predicateOperator: LYRPredicateOperator.like, value: "%%\(searchText)%%")
messageTextQuery.sortDescriptors = [NSSortDescriptor(key: "position", ascending: false)]

layerClient.execute(messageTextQuery) { results, error in
    if let results = results {
        // do stuff with results
    }
}

0 Answers0