ios - Parse.com user search without regex -
i have app have users user name , spot real name. allow users query find other users. query looks this:
pfquery *userquery = [pfuser query]; [userquery wherekey:kcpusername containsstring:[searchtext lowercasestring]]; pfquery *userrealnamequery = [pfuser query]; [usernamequery wherekey:kcpuserfullname containsstring: searchtext]; pfquery *userrealnamewithcapsquery = [pfuser query]; [userrealnamewithcapsquery wherekey:kcpuserfullname containsstring:[searchtext capitalizedstring]]; pfquery *userrealnamewithlowerquery = [pfuser query]; [userrealnamewithlowerquery wherekey:kcpuserfullname containsstring:[searchtext lowercasestring]]; pfquery *finalquery = [pfquery orquerywithsubqueries:@[userquery, userrealnamequery, userrealnamewithcapsquery, userrealnamewithlowerquery]];
this works great, returning list of users match searchtext. however, i've become aware containsstring uses regex, if have many users searching @ same time run 80 regex queries / min limitation in parse. using hasprefix: uses regex. query can think of use equalto: method, mean user must know looking , how spell names (either user or real).
any suggestions?
my final solution problem create separate field, call combined_names. field concatenation of real , user names (all lowercase). can single regex call on , same results. while not removing regex calls, goes 4 calls 1.
Comments
Post a Comment