why "path": "/\"_etag\"/?" is excluded from the excluded path in indexing policy of cosmosDB

Viewed 51

I was updating my indexing policy using the powershell but It is adding "path": "/\"_etag\"/?" property in excludedpath by default I want the Indexing policy to be

{
    "indexingMode": "consistent",
    "automatic": true,
    "includedPaths": [],
    "excludedPaths": [
        {
            "path": "/*"
        },
    ]
}

script I used

$indexPathExcluded = "/*"

$indexingPolicy = New-AzCosmosDBSqlIndexingPolicy  -ExcludedPath $indexPathExcluded -IndexingMode Consistent -Automatic $true

update-AzCosmosDBSqlContainer -ResourceGroupName myresourcename -AccountName myaccountname -DatabaseName mydatabasename -Name myCollectionname -IndexingPolicy $indexingPolicy

But with this I am getting result as

{
    "indexingMode": "consistent",
    "automatic": true,
    "includedPaths": [],
    "excludedPaths": [
        {
            "path": "/*"
        },
        {
            "path": "/\"_etag\"/?"
        }
    ]
}
1 Answers

etag is excluded by default from the indexing policy as an optimization by the service to reduce RU consumption on a property that has limited or no usefulness being indexed and used in a query.

etag is an internal system property used for optimistic concurrency control. The etag is generated by the service when an item is initially inserted then updated on every update made to it. You can view a sample for how to use OCC here.

As an internal property used for OCC, this property adds no value being indexed and used in queries. OCC checks don't use the index. And because the value changes on every update, including in the index policy would needlessly consume additional throughput (RU/s) as the value is reindexed each time.

Related