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 code for 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手册中排序规则文档中的可能字段。