|
| 1 | +To configure collation for your operation, create an instance of the |
| 2 | +`Collation <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Collation.html>`__ class. |
| 3 | + |
| 4 | +The following table describes the parameters that the ``Collation`` constructor accepts. |
| 5 | +It also lists the corresponding class property that you can use to read each |
| 6 | +setting's value. |
| 7 | + |
| 8 | +.. list-table:: |
| 9 | + :header-rows: 1 |
| 10 | + :widths: 20 60 20 |
| 11 | + |
| 12 | + * - Parameter |
| 13 | + - Description |
| 14 | + - Class Property |
| 15 | + |
| 16 | + * - ``locale`` |
| 17 | + - | Specifies the International Components for Unicode (ICU) locale. For a list of |
| 18 | + supported locales, |
| 19 | + see :manual:`Collation Locales and Default Parameters </reference/collation-locales-defaults/#supported-languages-and-locales>` |
| 20 | + in the {+mdb-server+} Manual. |
| 21 | + | |
| 22 | + | If you want to use simple binary comparison, use the ``Collation.Simple`` static |
| 23 | + property to return a ``Collation`` object with the ``locale`` set to ``"simple"``. |
| 24 | + | **Data Type**: {+string-data-type+} |
| 25 | + - ``Locale`` |
| 26 | + |
| 27 | + * - ``caseLevel`` |
| 28 | + - | *(Optional)* Specifies whether to include case comparison. |
| 29 | + | |
| 30 | + | When this argument is ``true``, the driver's behavior depends on the value of |
| 31 | + the ``strength`` argument: |
| 32 | + | |
| 33 | + | - If ``strength`` is ``CollationStrength.Primary``, the driver compares base |
| 34 | + characters and case. |
| 35 | + | - If ``strength`` is ``CollationStrength.Secondary``, the driver compares base |
| 36 | + characters, diacritics, other secondary differences, and case. |
| 37 | + | - If ``strength`` is any other value, this argument is ignored. |
| 38 | + | |
| 39 | + | When this argument is ``false``, the driver doesn't include case comparison at |
| 40 | + strength level ``Primary`` or ``Secondary``. |
| 41 | + | |
| 42 | + | **Data Type**: {+bool-data-type+} |
| 43 | + | **Default**: ``false`` |
| 44 | + - ``CaseLevel`` |
| 45 | + |
| 46 | + * - ``caseFirst`` |
| 47 | + - | *(Optional)* Specifies the sort order of case differences during tertiary level comparisons. |
| 48 | + | |
| 49 | + | **Data Type**: `CollationCaseFirst <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.CollationCaseFirst.html>`__ |
| 50 | + | **Default**: ``CollationCaseFirst.Off`` |
| 51 | + - ``CaseFirst`` |
| 52 | + |
| 53 | + * - ``strength`` |
| 54 | + - | *(Optional)* Specifies the level of comparison to perform, as defined in the |
| 55 | + `ICU documentation <https://unicode-org.github.io/icu/userguide/collation/concepts.html#comparison-levels>`__. |
| 56 | + | |
| 57 | + | **Data Type**: `CollationStrength <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.CollationStrength.html>`__ |
| 58 | + | **Default**: ``CollationStrength.Tertiary`` |
| 59 | + - ``Strength`` |
| 60 | + |
| 61 | + * - ``numericOrdering`` |
| 62 | + - | *(Optional)* Specifies whether the driver compares numeric strings as numbers. |
| 63 | + | |
| 64 | + | If this argument is ``true``, the driver compares numeric strings as numbers. |
| 65 | + For example, when comparing the strings "10" and "2", the driver treats the values |
| 66 | + as 10 and 2, and finds 10 to be greater. |
| 67 | + | |
| 68 | + | If this argument is ``false`` or excluded, the driver compares numeric strings |
| 69 | + as strings. For example, when comparing the strings "10" and "2", the driver |
| 70 | + compares one character at a time. Because "1" is less than "2", the driver finds |
| 71 | + "10" to be less than "2". |
| 72 | + | |
| 73 | + | For more information, see :manual:`Collation Restrictions </reference/collation/#restrictions>` |
| 74 | + in the {+mdb-server+} manual. |
| 75 | + | |
| 76 | + | **Data Type**: {+bool-data-type+} |
| 77 | + | **Default**: ``false`` |
| 78 | + - ``NumericOrdering`` |
| 79 | + |
| 80 | + * - ``alternate`` |
| 81 | + - | *(Optional)* Specifies whether the driver considers whitespace and punctuation as base |
| 82 | + characters for purposes of comparison. |
| 83 | + | |
| 84 | + | **Data Type**: `CollationAlternate <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.CollationAlternate.html>`__ |
| 85 | + | **Default**: ``CollationAlternate.NonIgnorable`` (spaces and punctuation are |
| 86 | + considered base characters) |
| 87 | + - ``Alternate`` |
| 88 | + |
| 89 | + * - ``maxVariable`` |
| 90 | + - | *(Optional)* Specifies which characters the driver considers ignorable when |
| 91 | + the ``alternate`` argument is ``CollationAlternate.Shifted``. |
| 92 | + | |
| 93 | + | **Data Type**: `CollationMaxVariable <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.CollationMaxVariable.html>`__ |
| 94 | + | **Default**: ``CollationMaxVariable.Punctuation`` (the driver ignores punctuation |
| 95 | + and spaces) |
| 96 | + - ``MaxVariable`` |
| 97 | + |
| 98 | + * - ``normalization`` |
| 99 | + - | *(Optional)* Specifies whether the driver normalizes text as needed. |
| 100 | + | |
| 101 | + | Most text doesn't require normalization. For more information about |
| 102 | + normalization, see the `ICU documentation <https://unicode-org.github.io/icu/userguide/collation/concepts.html#normalization>`__. |
| 103 | + | |
| 104 | + | **Data Type**: {+bool-data-type+} |
| 105 | + | **Default**: ``false`` |
| 106 | + - ``Normalization`` |
| 107 | + |
| 108 | + * - ``backwards`` |
| 109 | + - | *(Optional)* Specifies whether strings containing diacritics sort from the back of the string |
| 110 | + to the front. |
| 111 | + | |
| 112 | + | **Data Type**: {+bool-data-type+} |
| 113 | + | **Default**: ``false`` |
| 114 | + - ``Backwards`` |
| 115 | + |
| 116 | +For more information about collation, see the :manual:`Collation </reference/collation>` |
| 117 | +page in the {+mdb-server+} manual. |
0 commit comments