Query Meta.id with regex

document id are formed in the following fashion:

       order_productIdInt_customerIdInt_orderId
       order_123_5060_12

First, I read id is indexed and faster to query. so thinking of querying for orders for a specific product (say all orders for product id 123). I tried the following but it is not working:

    String regexId = "\\border_" + productId + "_.*\\b";
   Expression exp = Expression.property("id").regex(Expression.string(regexId));

but it finds no documents but i am sure there are documents. What am I doing wrong? While I intend to measure the performance, is there an advantage already to using the id field?

First, confirm that the document actually exists by doing a directly lookup by document Id.

To query for documents with Ids matching a certain criteria, you’d use something like this.

let searchQuery1 = QueryBuilder
        .select(SelectResult.expression(Meta.id),
                SelectResult.expression(Expression.property("name"))        )
        .from(DataSource.database(db))
        .where(Meta.id.regex(Expression.string("\\beng.*r.*\\b")))
    .limit(Expression.int(limit))

thanks…worked like a charm!