diacritic predicate

198 views
Skip to first unread message

Nicolas Gastaldi

unread,
Nov 12, 2014, 11:48:45 PM11/12/14
to realm...@googlegroups.com
Hello,

i am brazilian , and its typical to have many accented words in here, so i need to query my db with diacritic option, but when i set my predicate as 

objectsWithPredicate:[NSPredicate predicateWithFormat:@"Name CONTAINS[cd] '%@'",term];


it says 'NSDiacriticInsensitivePredicateOption not supported for string type' is there any possible workarounds or am i doing something wrong? 

thnx

JP Simard

unread,
Nov 13, 2014, 2:37:21 PM11/13/14
to Nicolas Gastaldi, realm...@googlegroups.com
Hi Nicolas, although Realm doesn't yet support diacritic insensitive queries, Core Foundation comes with a very flexible and robust string transformer called CFStringTransform, which can be used to normalize strings and semantically strip diacritics, among other operations.

You could store a normalized string property for each object you need to search against by applying the "Any-Latin; Latin-ASCII; Any-Lower" ICU transform.

--
You received this message because you are subscribed to the Google Groups "Realm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-cocoa...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-cocoa/6a393f6f-2a3f-4833-a449-1e23faeccd2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Edward Ishaq

unread,
Apr 6, 2015, 2:35:12 PM4/6/15
to realm...@googlegroups.com, nic...@nightly.com.br
Hi JP,

Will there be support for this in the near future ?
I'm having the same issue when trying to filter by string variable

Email.objectsWhere("self.address like[cd] %@", searchTerm as NSString)

JP Simard

unread,
Apr 6, 2015, 2:50:34 PM4/6/15
to Edward Ishaq, nic...@nightly.com.br, realm...@googlegroups.com
Adding ICU into Realm is on our roadmap, which will enable doing diacritic insensitive queries at runtime (along with more interesting features).

This is currently a low priority however, mostly because it's possible for you to store a diacritic-normalized version of your string in another property by using the CFStringTransform I mentioned earlier in this thread.

--
JP Simard




For more options, visit https://groups.google.com/d/optout.



{#HS:82384965-831#}

Private Email

unread,
Apr 6, 2015, 2:53:19 PM4/6/15
to JP Simard, nic...@nightly.com.br, realm...@googlegroups.com
Got it. Thanks for the quick reply

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages