Set Language Specific Rules for String Comparison设置字符串比较的语言特定规则
Use the Collation query bar option to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.使用排序规则查询栏选项可以为字符串比较指定特定于语言的规则,例如大小写和重音标记的规则。
Set Collation设置排序规则
In the Query Bar, click Options.在查询栏中,单击“选项”。Enter the在排序规则文档中输入locale
field in the collation document to specify the ICU Locale codefor the desired language in the Collation field.
locale
字段,以在排序规则字段中指定所需语言的ICU区域设置代码。
ExampleTo use the要使用汉语排序的pinyin
variant of the Chinese collation, use the following collation document:pinyin
变体,请使用以下排序文档:{ "locale" : "zh@collation=pinyin" }
As you type, the Find button is disabled and the Collation label turns red until a valid query is entered.键入时,“查找”按钮将被禁用,“排序规则”标签将变为红色,直到输入有效查询为止。Click Find to run the query and view the updated results.单击“查找”运行查询并查看更新的结果。
Clear the Query清除查询
To clear the query bar and the results of the query, click Reset.要清除查询栏和查询结果,请单击“重置”。
To Learn More了解更多信息
See the supported languages and locales section in the MongoDB Manual.请参阅MongoDB手册中支持的语言和地区部分。See the possible fields in a collation document in the MongoDB Manual.请参阅MongoDB手册中排序规则文档中可能的字段。