Bulk.find.collation()

On this page本页内容

Description描述

Bulk.find.collation(<document>)

New in version 3.4.版本3.4中的新功能。

Specifies the collation for the bulk writes. 指定批量写入的排序规则Append to Bulk.find() method to specify collation for the find operation.追加到Bulk.find()方法以指定查找操作的排序规则

The Bulk.find.collation() accepts the following collation document:Bulk.find.collation()接受以下排序规则文档:

{
   locale: <string>,
   caseLevel: <boolean>,
   caseFirst: <string>,
   strength: <int>,
   numericOrdering: <boolean>,
   alternate: <string>,
   maxVariable: <string>,
   backwards: <boolean>
}

When specifying collation, the locale field is mandatory; all other collation fields are optional. 指定排序规则时,locale字段是必需的;所有其他排序规则字段都是可选的。For descriptions of the fields, see Collation Document.有关这些字段的描述,请参阅排序规则文档

Field字段Type类型Description描述
locale string

The ICU locale. ICU区域设置。See Supported Languages and Locales for a list of supported locales.有关支持的语言环境列表,请参阅支持的语言和区域设置

To specify simple binary comparison, specify locale value of "simple".要指定简单的二进制比较,请指定"simple"locale值。

strength integer

Optional.可选。The level of comparison to perform. 要执行的比较级别。Corresponds to ICU Comparison Levels. 对应于ICU比较级别Possible values are:可能的值包括:

ValueDescription描述
1 Primary level of comparison. 初级比较。Collation performs comparisons of the base characters only, ignoring other differences such as diacritics and case.排序规则只对基本字符进行比较,而忽略其他差异,如变音符号和大小写。
2 Secondary level of comparison. 二级比较。Collation performs comparisons up to secondary differences, such as diacritics. 排序规则将执行到次要差异(如变音符号)的比较。That is, collation performs comparisons of base characters (primary differences) and diacritics (secondary differences). 也就是说,排序规则执行基本字符(主要差异)和变音符号(次要差异)的比较。Differences between base characters takes precedence over secondary differences.基本字符之间的差异优先于次要差异。
3

Tertiary level of comparison. 三级比较。Collation performs comparisons up to tertiary differences, such as case and letter variants. 排序规则执行最多三级差异的比较,例如大小写和字母变体。That is, collation performs comparisons of base characters (primary differences), diacritics (secondary differences), and case and variants (tertiary differences). 也就是说,排序规则执行基本字符(主要差异)、变音符号(次要差异)以及大小写和变体(第三差异)的比较。Differences between base characters takes precedence over secondary differences, which takes precedence over tertiary differences.基本字符之间的差异优先于次要差异,次要差异优先于三级差异。

This is the default level.这是默认级别。

4 Quaternary Level. 四级比较。Limited for specific use case to consider punctuation when levels 1-3 ignore punctuation or for processing Japanese text.仅限于在1-3级忽略标点符号或处理日语文本时考虑标点符号的特定用例。
5 Identical Level. 相同级别。Limited for specific use case of tie breaker.仅限于连接断路器的特定使用情况。

See ICU Collation: Comparison Levels for details.有关详细信息,请参阅ICU排序:比较级别

caseLevel boolean

Optional.可选。Flag that determines whether to include case comparison at strength level 1 or 2.确定是否在strength级别12包含案例比较的标志。

If true, include case comparison; i.e.如果为true,则包括案例比较;比如。

  • When used with strength:1, collation compares base characters and case.当与strength:1一起使用时,排序规则会比较基本字符和大小写。
  • When used with strength:2, collation compares base characters, diacritics (and possible other secondary differences) and case.当与strength:2一起使用时,排序规则会比较基本字符、变音符号(以及其他可能的次要差异)和大小写。

If false, do not include case comparison at level 1 or 2. 如果为false,则不包括1级或2级的案例比较。The default is false.默认值为false

For more information, see ICU Collation: Case Level.有关更多信息,请参阅ICU排序:大小写级别

caseFirst string

Optional.可选。A field that determines sort order of case differences during tertiary level comparisons.确定三级比较期间大小写差异排序顺序的字段。

Possible values are:可能的值包括:

ValueDescription描述
“upper” Uppercase sorts before lowercase.大写在小写之前排序。
“lower” Lowercase sorts before uppercase.小写在大写之前排序。
“off” Default value. 默认值。Similar to "lower" with slight differences. "lower"类似,但略有不同。See http://userguide.icu-project.org/collation/customization for details of differences.请参阅http://userguide.icu-project.org/collation/customization以解差别的详细信息。
numericOrdering boolean

Optional.可选。Flag that determines whether to compare numeric strings as numbers or as strings.确定是将数字字符串作为数字还是字符串进行比较的标志。

If true, compare as numbers; i.e. "10" is greater than "2".如果为true,则以数字进行比较;即"10"大于"2"

If false, compare as strings; i.e. "10" is less than "2".如果为false,则作为字符串进行比较;即"10"小于"2"

Default is false.

alternate string

Optional.可选。Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.字段,用于确定排序规则是否应将空格和标点符号视为基本字符以进行比较。

Possible values are:可能的值包括:

ValueDescription描述
"non-ignorable" Whitespace and punctuation are considered base characters.空格和标点符号被认为是基本字符。
"shifted" Whitespace and punctuation are not considered base characters and are only distinguished at strength levels greater than 3.空格和标点符号不被视为基本字符,只能在大于3的强度级别进行区分。

See ICU Collation: Comparison Levels for more information.更多信息请参见ICU排序:比较级别

Default is "non-ignorable".默认值为"non-ignorable"

maxVariable string

Optional.可选。Field that determines up to which characters are considered ignorable when alternate: "shifted". 字段,用于确定在alternate: "shifted"时最多可忽略哪些字符。Has no effect if alternate: "non-ignorable"如果是alternate: "non-ignorable",则无效

Possible values are:可能的值包括:

ValueDescription描述
"punct" Both whitespaces and punctuation are “ignorable”, i.e. not considered base characters.空格和标点符号都是“可忽略的”,即不被视为基本字符。
"space" Whitespace are “ignorable”, i.e. not considered base characters.空白是“可忽略的”,即不被视为基本字符。
backwards boolean

Optional.可选。Flag that determines whether strings with diacritics sort from back of the string, such as with some French dictionary ordering.标志,用于确定带变音符号的字符串是否从字符串的后面排序,例如使用某些法语词典排序。

If true, compare from back to front.如果为true,则从后到前进行比较。

If false, compare from front to back.如果为false,则从前面到后面进行比较。

The default value is false.默认值为false

normalization boolean

Optional.可选。Flag that determines whether to check if text require normalization and to perform normalization. 确定是否检查文本是否需要标准化以及是否执行标准化的标志。Generally, majority of text does not require this normalization processing.通常,大多数文本不需要这种规范化处理。

If true, check if fully normalized and perform normalization to compare text.如果为true,请检查是否完全规范化,并执行规范化以比较文本。

If false, does not check.如果为false,则不进行检查。

The default value is false.默认值为false

See http://userguide.icu-project.org/collation/concepts#TOC-Normalization for details.请参阅http://userguide.icu-project.org/collation/concepts#TOC-Normalization以了解更多信息。

Example示例

The following example initializes a Bulk() operations builder for the myColl collection and specifies a collation for the find filter.下面的示例初始化myColl集合的Bulk()操作生成器,并指定find筛选器的排序规则。

var bulk = db.myColl.initializeUnorderedBulkOp();
bulk.find( { category: "cafe" } ).collation({ locale: "fr", strength: 1 }).update( { $set: { status: "I", points: "0" } } );
bulk.execute();