Filters record using the json property when json present in a bin

Hi, I have JSON stored in one bin with ‘data’ as key. Now I want to filter records based on one of the JSON property value.

bin →

"data" : {
    "entity_id": "1234567",
    "store_id": "",
    "sub_merchant_id": "",
    "entity_type": "volvo_bus",
    "datetime": 1700564795635,
}

So basically I want to filter on the entity type where the value is “volvo_bus”.

I tried to do it this way

           QueryPolicy queryPolicy = new QueryPolicy();
            queryPolicy.setTimeout(10000);

            Statement statement = new Statement();
            statement.setNamespace("sample");
            statement.setSetName("bus");


            statement.setFilter(Filter.equal(  "data", "volvo_bus"));
           // statement.setFilter(Filter.equal(  "data", "entity_type")); // tried this as well.


            PartitionFilter partitionFilter =  PartitionFilter.range(startPartition,
                endPartition - startPartition + 1);

                RecordSet recordSet = client.queryPartitions(queryPolicy, statement, partitionFilter);
                while (recordSet.next()) {
                    Record record = recordSet.getRecord();
                    log.info(record)
               }
                   ....
manage sindex create string bus_key ns sample set bus bin data in mapkeys
manage sindex create string bus_values ns sample set bus bin data in mapvalues

The call never came to the while statement and got stuck at the client.queryPartitions method. Note: I have created a secondary index on the “data” bin “bus” set under “sample” namespace.

Can you share your createIndex() code?

I have updated my code and added the index create command.

If you have it working, then all good.