Home > other >  Cosmos DB - Is it safe to exclude system attributes like _ts, _rid and _self from indexing?
Cosmos DB - Is it safe to exclude system attributes like _ts, _rid and _self from indexing?

Time:09-23

When a container is created with default indexing policy, I noticed that _etag is automatically added to the excluded paths which is quite understandable because of it being opaque and all and you should not be building any application logic on its value.

What about the other system properties like _ts, _rid and _self?

Assuming I am never going to query on any of these attributes, is it safe to exclude these properties from indexing by adding these properties to the excluded paths in the container's indexing policy?

Or does Cosmos DB engine somehow uses these attributes internally for efficient querying or for some other purposes?

CodePudding user response:

So _rid and _self are never indexed so there is no need to explicitly exclude them in your indexing policy.

_ts is indexed so you could explicitly exclude that one if you want along with _etag which is excluded for you as you mention.

There is one property you cannot exclude and that is id. This will be indexed whether you want to or not unless you turn off indexing completely.

  • Related