Regex on id field not returning any results and throws no error

ENvrionment is Android, CBL 2.8.0. The id is set as follows:


which matches:


I want to filter out all orders for store 12, product 23 and did the following…it throws no error but no results either:

      int storeId = 12;
     int productId = 23;
    String reg = "^order_" + storeId + "_" + productId  + "_\\d+";
    Expression ex ="_id").regex(Expression.string(reg));
   // Expression ex ="id").regex(Expression.string(reg));
  // Expression ex ="_id").regex(Expression.value(reg));

none of them works. What am I doing wrong?

For the id property of a document you should be using the function as in this example. If it still doesn’t work then there is not much I can go off from this example. You’d have to show how you save the data and then query it to see if there is something wrong with either of those.

thanks! The data is synced from Syncgateway…so is not randomly generated at all. A typical document is as follows if queries in couchabse or even CBL itself:

{_id:'order_1_12_8977', docType:'order', storeId: 1, productId: 12, orderId: 9877, sourceStoreType:'GEN', orderedOn:'2021-01-21', processedOn:'2021-01-24'}

and a few more text fields. Currently, I am doing:

   Express ion ex ="docType").equalTo(Expression.string("order")).and(.....)

which works but coming from pouchdb + syncgateway, which lets us query on id field, I thought it would work here also.

I checked out the link you shared…looks like I just need to use WHERE on without Expression. Will give that a shot. thanks