MongoDB DBA · Question 497 · Single choice

14. Consider the following commands run in the mongo shell: db.createCollection( "signs", { "collation": { "locale": "fr" } } ) db.signs.createIndex( { "sign_text": 1 }, { "collation": { "locale": "es" } } ) db.signs.find( { "sign_text": "Bonjour Québec" } ) Which of the following statements is true about the final .find() commmand? Choose the best answer:

Answer options

  1. A.
    mongod will match documents using the French ("fr") collation.
  2. B.
    mongod will match documents using the Spanish ("es") collation.
  3. C.
    mongod will throw an error because the collection and the index have conflicting collations.
  4. D.
    mongod will throw an error because no collation was specified.
  5. E.
    mongod will match documents using either the French ("fr") or the Spanish ("es") collation.

Answer confidence: High

Correct answer: A

Explanation language: Chinese

这次 find 没有显式指定 collation,就继承集合的默认 collation,即建集合时指定的 fr(法语),因此按法语规则比较,选 B。用 es 建的那个索引因为 collation 与查询不一致而不会被这次查询使用——不会报错,只是不走该索引,所以 A、C、D、E 都不对。

Papers containing this question

This question appears in 1 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗