collation – Tools for working with collations.¶
Tools for working with collations.
- class pymongo.collation.Collation(locale: str, caseLevel: Optional[bool] = None, caseFirst: Optional[str] = None, strength: Optional[int] = None, numericOrdering: Optional[bool] = None, alternate: Optional[str] = None, maxVariable: Optional[str] = None, normalization: Optional[bool] = None, backwards: Optional[bool] = None, **kwargs: Any)¶
locale: (string) The locale of the collation. This should be a string that identifies an ICU locale ID exactly. For example,
en_USis valid, but
en-USare not. Consult the MongoDB documentation for a list of supported locales.
caseLevel: (optional) If
True, turn on case sensitivity if strength is 1 or 2 (case sensitivity is implied if strength is greater than 2). Defaults to
caseFirst: (optional) Specify that either uppercase or lowercase characters take precedence. Must be one of the following values:
strength: (optional) Specify the comparison strength. This is also known as the ICU comparison level. This must be one of the following values:
Each successive level builds upon the previous. For example, a strength of
SECONDARYdifferentiates characters based both on the unadorned base character and its accents.
numericOrdering: (optional) If
True, order numbers numerically instead of in collation order (defaults to
alternate: (optional) Specify whether spaces and punctuation are considered base characters. This must be one of the following values:
maxVariable: (optional) When alternate is
SHIFTED, this option specifies what characters may be ignored. This must be one of the following values:
normalization: (optional) If
True, normalizes text into Unicode NFD. Defaults to
backwards: (optional) If
True, accents on characters are considered from the back of the word to the front, as it is done in some French dictionary ordering traditions. Defaults to
kwargs: (optional) Keyword arguments supplying any additional options to be sent with this Collation object.
- class pymongo.collation.CollationStrength¶
An enum that defines values for strength on a
- PRIMARY = 1¶
Differentiate base (unadorned) characters.
- SECONDARY = 2¶
Differentiate character accents.
- TERTIARY = 3¶
Differentiate character case.
- QUATERNARY = 4¶
Differentiate words with and without punctuation.
- IDENTICAL = 5¶
Differentiate unicode code point (characters are exactly identical).
- class pymongo.collation.CollationAlternate¶
An enum that defines values for alternate on a
- NON_IGNORABLE = 'non-ignorable'¶
Spaces and punctuation are treated as base characters.
- SHIFTED = 'shifted'¶
Spaces and punctuation are not considered base characters.
Spaces and punctuation are distinguished regardless when the
Collationstrength is at least
- class pymongo.collation.CollationCaseFirst¶
An enum that defines values for case_first on a
- UPPER = 'upper'¶
Sort uppercase characters first.
- LOWER = 'lower'¶
Sort lowercase characters first.
- OFF = 'off'¶
Default for locale or collation strength.