Docs HomeMongoDB Compass

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设置排序规则

  1. In the Query Bar, click Options.在查询栏中,单击“选项”。
  2. Enter the locale field in the collation document to specify the ICU Locale code for the desired language in the Collation field.在排序规则文档中输入locale字段,以在排序规则字段中指定所需语言的ICU区域设置代码

    Example

    To 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.键入时,“查找”按钮将被禁用,“排序规则”标签将变为红色,直到输入有效查询为止。

  3. 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了解更多信息