I am trying to remove the default indexes which are created for a new collection:
{
"indexingMode": "lazy",
"automatic": true,
"includedPaths": [
{
"path": "/*",
"indexes": [
{
"kind": "Range",
"dataType": "Number",
"precision": -1
},
{
"kind": "Hash",
"dataType": "String",
"precision": 3
}
]
},
{
"path": "/"_ts"/?",
"indexes": [
{
"kind": "Range",
"dataType": "Number",
"precision": -1
},
{
"kind": "Hash",
"dataType": "String",
"precision": 3
}
]
}
],
"excludedPaths": []
}
As far as I understand, this will index every attribute in every resource and its sub-resources.
When attempting to exclude everything using this:
collection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath
{
Path = "/*"
});
client.ReplaceDocumentCollectionAsync(collection).Wait();
I get the following error on ReplaceDocumentCollectionAsync()
:
The indexing path '/*' could not be accepted. Please ensure that the
path is unique across all sets of indexing paths and it's valid.
I want to be able to define my own, custom, index paths. In order to do this, I need to remove the default indexes (which index everything).
UPDATE
I have removed the index by assigning the includes to an empty collection AND by excluding all paths:
collection.IndexingPolicy.IncludedPaths = new Collection<IncludedPath>();
collection.IndexingPolicy.ExcludedPaths = new Collection<ExcludedPath>();
collection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath
{
Path = "/*"
});
Note 1: For some reason, if only doing the first statement, nothing changes on the index policy... and without error.
Note 2: ExcludePaths
has to be set to an empty collection initially or else (if the path already exists) it will detect the conflict and throw a error (when doing a ReplaceDocumentCollectionAsync of course).
Indexing document:
{
"indexingMode": "lazy",
"automatic": true,
"includedPaths": [
{
"path": "/"_ts"/?",
"indexes": [
{
"kind": "Range",
"dataType": "Number",
"precision": -1
},
{
"kind": "Hash",
"dataType": "String",
"precision": 3
}
]
}
],
"excludedPaths": [
{
"path": "/*"
}
]
}
I assume that the /_ts/?
path is mandatory.
See Question&Answers more detail:
os