how to perform a query comparing number values

0 votes

I am trying this example query


  1. String key2 = "age";     
  2. int value2 = 29;      
  3. Query q2 = QueryBuilder.Build(key2, value2, Operator.GREATER_THAN); // Build query q2 for key2 equal to age and value2 equal to 30         
  4. Storage storage = storageService.FindDocumentsByQuery(dbName,collectionName,q2);  


with a json document {"age":"30","name":"Nick"} and i get the result

com.shephertz.app42.paas.sdk.csharp.App42NotFoundException: {"app42Fault":{"httpErrorCode":404,"appErrorCode":2608,"message":"Not Found","details":"No document in the collection 'testing' exists for given query"}}


is it not possibly to do queries with number comparisons?

asked Sep 18, 2016 in Android by aaron Hatchard (11 points)

1 Answer

+1 vote
Hi Aaron,

You can apply this query on numbers but in the json doc, the value "30" is a string not a number. Hence you are getting this exception.

Please check and let me know if this is not the problem.


answered Sep 19, 2016 by rajeev.etc (1,660 points)
Thanks, that fixed the issue. related to that then, I was using

JSONClass json = new JSONClass();
json.Add("name","Bryan" );
json.Add("lat", 44);

to create the json that is sent to the backend, but that only creates the document with the name attribute and value. If I write a json string like:

string json = "{ \"name\":\"Bryan\", \"age\":" + 44 + "}"

and send that, a document is created with both attributes and values. Is it not possible to use the JSONClass to add numbers in  a document?
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on