cqengine icon indicating copy to clipboard operation
cqengine copied to clipboard

Case insensitive search no supported

Open Sharadk007 opened this issue 3 years ago • 2 comments

Hi,

I want to use case insensitive in like query which seems to be not supported with cq

Sharadk007 avatar Aug 26 '21 07:08 Sharadk007

we're also looking for this feature. Any updates ?

ankursharma180 avatar Sep 16 '21 15:09 ankursharma180

Doing this completely transparently in CQEngine would be non-trivial, because fundamentally uppercase and lowercase characters are represented by different bytes. It means many indexes like HashIndex would not support case insensitive search.

However it's pretty easy to solve this/workaround it in your application.

Let's say you wanted case-insensitive search for a field MyObject.foo -

  1. Define a FOO_LOWERCASE attribute, which returns object.foo.toLowerCase(). This way you won't actually need to modify your domain objects or store the lowercase text per-se (if you don't want to), the attribute will convert it on-the-fly.

  2. When constructing your query, convert the query text .toLowerCase() and use that in your query on the FOO_LOWERCASE attribute.

You can then add any indexes on the FOO_LOWERCASE attribute if you wish.

Hope that helps, Niall

On Thu 16 Sep 2021, 16:26 ankursharma180, @.***> wrote:

we're also looking for this feature. Any updates ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/npgall/cqengine/issues/290#issuecomment-921003352, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVYTCS4G3OWW2MUIZG27PDUCIEEBANCNFSM5C2WYYTQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

npgall avatar Sep 16 '21 18:09 npgall