documentdb-indexing
Skill6 starsChanged 7 months agoMITView on GitHub
Index-type selection and shape guidance for Azure DocumentDB — when to use single-field, compound (ESR), multikey, wildcard, hashed, 2dsphere, TTL, and vector indexes; query-pattern → index-shape cookbook; per-collection index budget; DocumentDB-specific preference for `textSearch` over community `$text`. Use when designing or reviewing indexes, choosing an index type for a query pattern, or deciding whether an additional index is worth the write cost.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- documentdb-azure-deploymentSkill
- documentdb-connectionSkill
- documentdb-data-modelingSkill
- documentdb-driverSkill
- documentdb-full-text-searchSkill
- documentdb-high-availabilitySkill
- documentdb-local-deploymentSkill
- documentdb-mcp-setupSkill
- documentdb-monitoringSkill
- documentdb-natural-language-queryingSkill
- documentdb-query-optimizationSkill
- documentdb-query-optimizerSkill
- documentdb-securitySkill
- documentdb-shardingSkill
- documentdb-storageSkill
- documentdb-vector-searchSkill
The file
Files
Indexing Strategies — Azure DocumentDB
Companion skill to documentdb-query-optimizer. That skill answers "why is this query slow?"; this one answers "which index should I create, and what shape should it take?".
Azure DocumentDB supports the standard MongoDB index types. Only _id is created automatically — every other index must be created explicitly. Default limit: 64 single-field indexes per collection (extendable to 300 on request).
Index engine types
_idvs regular indexes: The_idindex is a B-tree, created automatically, and cannot be dropped. For sharded collections the_idkey is composite — it includes a hash of the shard key. All other indexes created viacreateIndexare RUM indexes; the exception is geospatial indexes (2dsphere,2d), which are GiST indexes.
Rules
- index-single-field — When a single-field index is enough; direction, options (
unique,sparse,partial, collation). - index-compound-esr — Compound index design via ESR (Equality → Sort → Range); prefer one compound over many singles.
- index-multikey-arrays — Indexing array fields; the one-array-per-compound (parallel-array) restriction; multikey can't cover queries.
- index-text-prefer-textsearch — On Azure DocumentDB, prefer the
textSearchindex +$searchover community$textindexes. - index-wildcard-dynamic-schemas — Wildcard indexes for truly dynamic schemas; cost vs benefit; scope the prefix.
- index-hashed-shard-keys — Hashed indexes for even distribution; when sharding becomes necessary; shard-key alignment; range-query caveats.
- index-2dsphere-geospatial — GeoJSON types,
[longitude, latitude]order,$near/$geoWithin/$geoIntersects. - index-ttl-expiry — TTL indexes:
expireAfterSecondssemantics, date-field requirement, monitoring. - index-count-budget — Keep 5–15 indexes per collection; review
$indexStats; drop unused. - index-lifecycle-drop-hide — Safe lifecycle: inventory → detect redundancy →
hideIndex→dropIndex. The_idindex cannot be dropped. - index-pattern-cookbook — Query-pattern → index-shape cookbook (equality+sort, multi-equality, selectivity ordering, $eq + $in mix, range+sort, equality+range, hybrid, partial index for large arrays).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

