Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Android, how do I make a case-insensitive query on Kinvey datastore?

I am using Kinvey as my back-end for my android app. I have followed the guide on their datastore querying found here. It seems that the queries are case-sensitive.

How do I make a case-insensitive query?

like image 763
janakagamini Avatar asked Dec 02 '25 11:12

janakagamini


1 Answers

I posted the same question in the Kinvey forums, and I got the following answer:

The Query class has a regex(String field, String regex) method which you can use for this by defining a case-insensitive regex.

Something like: Query myQuery = new Query().regex("myJSONKey", myRegex);

Here is the documentation: http://devcenter.kinvey.com/android/reference/api/java/reference/com/kinvey/java/Query.html#regEx(java.lang.String, java.lang.Object)

Credit to Edward Fleming.

However, for anyone who is interested, according to here:

It should be noted that searching with regex's case insensitive /i means that mongodb cannot search by index, so queries against large datasets can take a long time.

I believe Kinvey uses mongodb for their datastore. Anyways, I used the suggestion mention in the same post, and it works perfectly.

like image 191
janakagamini Avatar answered Dec 05 '25 01:12

janakagamini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!