Exception when adding a range index to the Azure DocumentDB collection

I am trying to add a range index to a specific property in the Azure DocumentDB collection, as described in this article. When my code to create the collection is executed, I get the following error:

The special required indexing path \\ "\ / \\" is not provided in any set of path types. Please indicate this path in one of the sets.

The code I use to create the collection is:

var collection = new DocumentCollection { id = "myCollectionID" };

collection.IndexingPolicy.IncludedPaths.Add(new IndexingPath
{
    IndexType = IndexType.Range,
    Path = "/\"TimeStamp\"/\"Epoch\"/?",
    NumericPrecision = 7
});

this._client.CreateDocumentCollectionAsync(database.SelfLink, collection);

The code works if I set the index path to just "/", but I would prefer to create an index for certain properties. What am I doing wrong?

+4
source share
1 answer

"/" IncludedPath, :

var collection = new DocumentCollection { id = "myCollectionID" };

collection.IndexingPolicy.IncludedPaths.Add(new IndexingPath
{
    IndexType = IndexType.Range,
    Path = "/\"TimeStamp\"/\"Epoch\"/?",
    NumericPrecision = 7
});

collection.IndexingPolicy.IncludedPaths.Add(new IndexingPath
{
    IndexType = IndexType.Hash,
    Path = "/"
});

this._client.CreateDocumentCollectionAsync(database.SelfLink, collection);

, , :

var collection = new DocumentCollection { id = "myCollectionID" };

collection.IndexingPolicy.IncludedPaths.Add(new IndexingPath
{
    IndexType = IndexType.Range,
    Path = "/\"TimeStamp\"/\"Epoch\"/?",
    NumericPrecision = 7
});

collection.IndexingPolicy.ExcludedPaths.Add("/");

this._client.CreateDocumentCollectionAsync(database.SelfLink, collection);

DocumentDB , "/", . , .

+5

All Articles