Search for case insensitive data from Parse using javascript

At this point in time you aren't able to perform case insensitive searches via a query.

A very easy workaround for this however, is to store a lower case version of the field you need to do this query on.

Creating The Item

var Product = Parse.Object.extend("product");
var newProduct = new Product();
var productName = "Temp4Product";
newProduct.set("name",productName);
newProduct.set("name_lowercase",productName.toLowerCase());
newProduct.save(); 

Performing the query

var search_data="Temp";
var product = Parse.Object.extend("product");
var query = new Parse.Query(product);

query.contains("name_lowercase",search_data.toLowerCase()); 
query.find({
     success: function(results) {
        console.log("Total Product Found : "+results.length);
        printSearchProducts(results,query);  //custom method to print product detail
     },
     error: function(error) {
         console.log("Error: " + error.code + " " + error.message);
     }
 });

Note in the above example I've used the string.toLowerCase() function, however there may be a more appropriate function for you to use. Basically you want to find a way to "simplify" your data so that you can perform the appropriate query.


For that you can use Parse.Query's matches() function, which even it's not indicated in its documentation page, but you can use it like this :

query.matches(key, value, 'i');

Hope that can help.