Courseiva
Sharding →hardMultiple Choice

C100DBA Sharding Practice Question

Exhibit

{ "ok" : 0, "errmsg" : "a sharded collection must have an index starting with the shard key", "code" : 85, "codeName" : "ShardKeyNotFound"levant }

Refer to the exhibit. An administrator attempts to execute the shardCollection command but receives the displayed error message. What is the root cause of this failure?

⚠ Common exam trap

Candidates often think MongoDB automatically creates the required index when sharding a collection, leading to unexpected command failures due to missing index prefixes.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

The collection lacks a supporting index whose key pattern matches or starts with the fields specified in the shard key definition.

MongoDB requires an explicit index whose prefix matches the designated shard key before sharding a collection. The error indicates that no such index exists on the collection, preventing the query router from establishing the necessary routing boundaries. Creating the correct index prior to running shardCollection resolves this issue.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    The collection lacks a supporting index whose key pattern matches or starts with the fields specified in the shard key definition.

    Why this is correct

    The collection lacks a supporting index whose key pattern matches or starts with the fields specified in the shard key definition. MongoDB enforces this prerequisite to ensure that every sharded collection has an underlying index capable of efficiently locating document chunk boundaries.

  • ✗

    The target database has not been enabled for sharding using the enableSharding administrative command.

    Why it's wrong here

    Sharding a collection requires the database to be sharded first; without enableSharding, shardCollection returns the error shown. It is tempting because enableSharding is genuinely required, but the stem's error points to the collection already existing as unsharded, so the missing step is a different prerequisite.

  • ✗

    The specified shard key contains an unsupported array field that violates BSON multi-key index constraints.

    Why it's wrong here

    The specified shard key contains an unsupported array field that violates BSON multi-key index constraints. While array fields can cause sharding restrictions, this specific error code explicitly points to the complete absence of a matching index prefix.

  • ✗

    The config server replica set is currently undergoing an election and cannot process metadata write operations.

    Why it's wrong here

    Election of the config server replica set does not block shardCollection; metadata writes continue through the primary. It is tempting because elections disrupt availability, but the actual cause is that sharding requires the collection to be empty or indexed on the shard key, which the error indicates.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

Courseiva writes every C100DBA question from scratch — 222 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official MongoDB exam blueprint

This C100DBA practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DBA exam.