objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

Improve support for other languages (UTF-8 characters) in queries

Open softkot opened this issue 8 years ago • 2 comments

Let's get a simple object with Id and Indexed field called name. Then fill it with two lagnguage values (russian and english in my case). Now make a query like

query().order(CallTheme_.name).build().subscribe().observer ...

The result is shown in application screenshot and you can see that case insensitive collation order for english language is different that a collation order for russian, i.e. did't work for russian either.

image

softkot avatar Mar 01 '17 05:03 softkot

Will be post 1.0 - ideas are already appreciated...

greenrobot avatar Jul 21 '17 16:07 greenrobot

This also affects other query functionalities, e.g.

  • create a query condition on a string that matches both upper and lower case UTF-8 characters (originally #684)
  • create a unique index on a string property that ignores case of UTF-8 characters (originally #806)
  • create a query condition on a string that matches all variants with diacritics (e.g. o should match o, ó and ö) (originally from #499)

A workaround to achieve this already, is to create a second string property that stores the original value with e.g. diacritics removed or mapped to lower case or ASCII only depending on your use case. Then use that property for queries and ordering. For example:

@Entity
data class User(
        @Id 
        var id: Long = 0,
        // actual value
        var name: String? = null,
        // value used for searching, modified in whichever way necessary
        // (e.g. strip diacritics, all lower case, ...)
        var nameSearch: String? = null
)

greenrobot-team avatar Nov 15 '22 06:11 greenrobot-team