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
- A.mongod will match documents using the French ("fr") collation.
- B.mongod will match documents using the Spanish ("es") collation.
- C.mongod will throw an error because the collection and the index have conflicting collations.
- D.mongod will throw an error because no collation was specified.
- 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 都不对。