collation – Tools for working with collations.
Tools for working with collations.
- class
pymongo.collation.
Collation
(locale, caseLevel=None, caseFirst=None, strength=None, numericOrdering=None, alternate=None, maxVariable=None, normalization=None, backwards=None, **kwargs)
Parameters:
locale: (string) The locale of the collation. This should be a stringthat identifies an ICU locale ID exactly. For example,
en_US
isvalid, buten_us
anden-US
are not. Consult the MongoDBdocumentation for a list of supported locales.caseLevel: (optional) If
True
, turn on case sensitivity ifstrength is 1 or 2 (case sensitivity is implied if strength isgreater than 2). Defaults toFalse
.caseFirst: (optional) Specify that either uppercase or lowercasecharacters take precedence. Must be one of the following values:
- strength: (optional) Specify the comparison strength. This is alsoknown as the ICU comparison level. This must be one of the followingvalues:
PRIMARY
SECONDARY
TERTIARY
(the default)QUATERNARY
IDENTICAL
Each successive level builds upon the previous. For example, astrength of SECONDARY
differentiatescharacters based both on the unadorned base character and its accents.
numericOrdering: (optional) If
True
, order numbers numericallyinstead of in collation order (defaults toFalse
).alternate: (optional) Specify whether spaces and punctuation areconsidered base characters. This must be one of the following values:
NON_IGNORABLE
(the default)SHIFTED
- maxVariable: (optional) When alternate is
SHIFTED
, this option specifies whatcharacters may be ignored. This must be one of the following values:
normalization: (optional) If
True
, normalizes text into UnicodeNFD. Defaults toFalse
.backwards: (optional) If
True
, accents on characters areconsidered from the back of the word to the front, as it is done in someFrench dictionary ordering traditions. Defaults toFalse
.kwargs: (optional) Keyword arguments supplying any additional optionsto be sent with this Collation object.
- class
pymongo.collation.
CollationStrength
An enum that defines values for strength on a
Collation
.
- class
pymongo.collation.
CollationAlternate
An enum that defines values for alternate on a
Collation
.
Spaces and punctuation are distinguished regardless when theCollation
strength is at leastQUATERNARY
.
- class
pymongo.collation.
CollationCaseFirst
An enum that defines values for case_first on a
Collation
.
- class
pymongo.collation.
CollationMaxVariable
An enum that defines values for max_variable on a
Collation
.