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

CASE_INSENSITIVE string query does not work with Cyrillic language

Open arnis71 opened this issue 5 years ago • 5 comments

Issue Basics

  • ObjectBox version (are using the latest version?): 2.3.4
  • Reproducibility: always

Reproducing the bug

Description

When querying db by string pattern in Russian case sensitivity option does not work. E.g given name "Андрей", case insensitive query "андрей" will fail to find it.

Code

orderDesc(Message_.timestamp)
    .startsWith(Message_.dialogId, it.dialogId).and()
    .contains(
             Message_.body,
             pattern,
             QueryBuilder.StringOrder.CASE_INSENSITIVE
      )

Entities

@Entity
data class Message(
    @Index val uuid: String = newUuid(),
    val body: String = "",
    val dialogId: String = "",
    var timestamp: Long = TimeSync.time,
    ...
)

arnis71 avatar Apr 02 '19 08:04 arnis71

As far as I know ordering by case only supports ASCII characters. This is also indicated by the docs. http://objectbox.io/files/objectbox-java/current/io/objectbox/query/QueryBuilder.html#CASE_SENSITIVE http://objectbox.io/files/objectbox-java/current/io/objectbox/query/QueryBuilder.html#order-io.objectbox.Property-int-

-Uwe

greenrobot-team avatar Apr 02 '19 12:04 greenrobot-team

As far as I know ordering by case only supports ASCII characters. This is also indicated by the docs. http://objectbox.io/files/objectbox-java/current/io/objectbox/query/QueryBuilder.html#CASE_SENSITIVE http://objectbox.io/files/objectbox-java/current/io/objectbox/query/QueryBuilder.html#order-io.objectbox.Property-int-

-Uwe

I am not concerned about ordering but rather about searching and finding an item.

arnis71 avatar Apr 02 '19 12:04 arnis71

@greenrobot-team ordering can be dropped to reproduce issue.

arnis71 avatar Apr 02 '19 12:04 arnis71

@arnis71 Sorry, I misread. But the same applies for a contains-query. Case sensitivity currently only works on the ASCII character set. http://objectbox.io/files/objectbox-java/current/io/objectbox/query/QueryBuilder.StringOrder.html#CASE_INSENSITIVE

-Uwe

greenrobot-team avatar Apr 02 '19 13:04 greenrobot-team

Seriously need case sensitivity covering at least extended ascii characters. As it stands now, not only Cyrillic, but German, French, Spanish, Italian don't work fully (given the accent letters).

XilinJia avatar Oct 21 '21 10:10 XilinJia

Just to note this here as well: a workaround is to add another property for searching and store the original value with diacritics removed and case mapped in whichever way is suitable for your use case.

greenrobot-team avatar Nov 14 '22 09:11 greenrobot-team

Related issues: #46, #499, #806 - not sure if we need those three and this one to track it.

greenrobot avatar Nov 14 '22 09:11 greenrobot

Moving the discussion about improving support for other languages to #46.

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