2

When removing indexing, I get the following error when trying to insert a document:

{{
  "code": "BadRequest",
  "message": "Message: {\"Errors\":[\"Indexing mode value cannot be 'none' when automatic indexing is specified as 'true'.\"]}..."
}}

I am using the SDK to do this:

collection.IndexingPolicy.IndexingMode = IndexingMode.None;

client.ReplaceDocumentCollectionAsync(collection).Wait();

I cannot find anything online with regards to this error or for specifying automatic indexing to true/false.

Dave New
  • 38,496
  • 59
  • 215
  • 394

1 Answers1

2

Looks like this is missing in the docs.

Automatic Indexing needs to be set to false for IndexingMode.None.

collection.IndexingPolicy.Automatic = false;

collection.IndexingPolicy.IndexingMode = IndexingMode.None;

client.ReplaceDocumentCollectionAsync(collection).Wait();
Andrew Liu
  • 8,045
  • 38
  • 47
  • Ah thanks. So, would this be the means of providing your own indexing entirely? Provided that the policy is set to lazy or consistent, of course. As I understand, the default, automatic index essentially creates a hash and range index on every resource (and subresource) attribute, which is complete overkill in many cases. – Dave New Nov 28 '15 at 04:04
  • 1
    These settings will turn indexing completely off. If you are looking to apply custom index policies, you will want to define custom paths. By default, a wildcard path, `/*`, is included in the indexing policy, which can be interpretative as indexing every property under the root document. To switch over completely to a custom index policy, exclude the root wildcard path ,`/*`, and include only your custom paths (e.g. `/prop/subprop/?`) – Andrew Liu Nov 28 '15 at 06:13
  • You can find a reference here: https://azure.microsoft.com/en-us/documentation/articles/documentdb-indexing-policies/ – Andrew Liu Nov 28 '15 at 06:14
  • I cannot seem to exclude all with the `/*` path. I get the following error: _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'm using lazy mode and the indexes are set as default. – Dave New Nov 29 '15 at 10:34
  • I created a question for this [here](http://stackoverflow.com/questions/33981829/documentdb-removing-default-indexing). – Dave New Nov 29 '15 at 10:40
  • One more intuitiveness of microsoft is that if the indexing is None then TTL cannot be set. I just cannot figure out what is the relation between this. Microsoft creates complex matrixes of what works with what and not. – SijuMathew Jan 05 '21 at 11:00