Skip to content

[IOT Lab] Suggestion: Use fluent builder pattern for indexing policy for better readability #21

@deborahc

Description

@deborahc

The code for tuning the indexing policy may be easier to read if you use the fluent indexing policy builder:

Current code:
// Tune the indexing policy for write-heavy workloads by only including regularly queried paths.
// Be careful when using an opt-in policy as we are below. Excluding all and only including certain paths removes
// Cosmos DB's ability to proactively add new properties to the index.
telemetryContainerDefinition.IndexingPolicy.ExcludedPaths.Clear();
telemetryContainerDefinition.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/*" }); // Exclude all paths.
telemetryContainerDefinition.IndexingPolicy.IncludedPaths.Clear();
telemetryContainerDefinition.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/vin/?" });
telemetryContainerDefinition.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/state/?" });
telemetryContainerDefinition.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/partitionKey/?"

See example: https://gist.github.com/deborahc/57b996e5f1dd82fcc1aacf00621c2459

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions