Start a new topic

Compound Queries in Java sdk

Can you join more then two queries together with or's or and's?

My issue is I am trying to build a query based off of the fields on a object. If I only use one field it works fine however as soon as I use more then one field it fails. Code is below:

//builds a query to pass to kinvey

public static Query buildQuery(String stringToSearch, Class> currentClass) {

//stringToSearch = stringToSearch.toLowerCase();

Query query, mutiQuery = new Query();

Field[] newFields = currentClass.getFields(); //get the fields on the current class

for (int i = 0; i

if (newFields[i].getType() == String.class) { //make sure it is a string field we are accessing

if(mutiQuery.isQueryEmpty()) { //the first query is empty so make sure it is not empty

mutiQuery = mutiQuery.regEx(newFields[i].getName(), stringToSearch);

} else { //this will then find the other strings and join them in a or

SimpleLogger.log("This is a string: " + newFields[i].getName()); //if I remove these 4 statements it works fine

query = new Query();

query = query.regEx(newFields[i].getName(), stringToSearch);



} else {

SimpleLogger.log("Not a string");



return mutiQuery;


I have tried both regEx as well as .equals no dice on either. Anyone have an idea what is going on with this? This is version 2.6.7 on the java sdk. I will be updating in a bit to see if that is the problem.
1 Comment

Never mind it is working fine now for some reason. I am only having a issue with object id field but i think it is a completely unrelated issue.
Login or Signup to post a comment