Start a new topic

Case-insensitive Query

I have followed this guide on querying datastore: http://devcenter.kinvey.com/android/guides/datastore#querying but it seems that the query is case-sensitive.



How do I make a case-insensitive query?

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)
Thank you Edward.



I'm new at this so I hadn't used regex before. So I beleive "myRegex" would be something like:



/^query_string/i



Correct?
http://devcenter.kinvey.com/android/reference/api/java/reference/com/kinvey/java/Query.html#regEx(java.lang.String, java.lang.Object)

explicitly says

> A regex must begin with a carat `^`, **and case-insensitive queries `/i` are not supported.**



So not supported then?
Hey, yeah, do to the performance implications of supporting case-insensitive queries we had to disable the feature.



I will update the javadocs to remove that.
Login or Signup to post a comment