An Azure NoSQL database service for app development.
Index Object without recursion
As a CosmosDB (SQL API) user I would like to index all non object or array properties inside of an object.
We have a sizable data set that is very dynamic from object to object, however we currently restrict users to querying records by only top level properties inside the data object.
Give the data set below I would like to configure my indexing policy to not recurse beyond the properties inside of data. I have not found a way to support this based on what is in the docs and many attempts in cosmos have proved fruitless.
[
{
"partitionKey": "f402a704-19bb-4f4d-93e6-801c50280cf6",
"id": "4a7a11e5-00b5-4def-8e80-132a8c083f24",
"data": {
"country": "Belgium",
"employees": 250,
"teammates": [
{ "name": "Jake", "id": 123 ...},
{ "name": "kyle", "id": 3252352 ...}
],
"user": {
"name": "Brian",
"addresses": [{ "city": "Moscow" ...}, { "city": "Moscow" ...}]
}
}
},
{
"partitionKey": "f402a704-19bb-4f4d-93e6-801c50280cf6",
"id": "36b563cc-1db9-48cb-82cd-eba0253990de",
"data": {
"Co": 1,
"Mth": "2020-03-01T00:00:00",
"Vendor": 9702,
"address": { "city": "Moscow", "state": "ohio" ...},
"jobs": [{ "name": "UPS Store" ...}]
}
},
{
"partitionKey": "f402a704-19bb-4f4d-93e6-801c50280cf6",
"id": "368d6090-70f7-458e-9146-1cb1ad5b7f5c",
"data": {
"DocName": "new test doc",
"id": 234234,
"user_permissions": ["read", "write", "delete"]
}
}
]
Policies like /data/* will not work because it would then index /data/teamates/name ... and so on.
/data/? => assumes data is a value type which it never will be so this doesn't work.
/data/ and /data/*/? and /data/*? are not accepted by cosmos as valid policies.
Only value types in the data object will ever be queried on and therefor those properties need to be indexed.
I have tried many iterations but it seems that options don't work for various reasons, is there a way to support what I am trying to do?