Skip to content

Commit e45e033

Browse files
authored
DOCSP-49849 - Collation (#628)
1 parent 502746c commit e45e033

File tree

9 files changed

+193
-19
lines changed

9 files changed

+193
-19
lines changed

source/crud/bulk-write.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ parameters:
133133

134134
* - ``collation``
135135
- | *Optional.* The language collation to use when sorting results. See the
136-
:manual:`{+mdb+server+} manual</reference/command/delete/#std-label-deletes-array-collation>`
137-
for more information.
136+
:ref:`<csharp-bulk-write-collation>` section of this page for more information.
138137
|
139138
| **Data Type:** `Collation <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Collation.html>`__
140139
| **Default:** ``null``
@@ -228,9 +227,8 @@ constructor accepts the following parameters:
228227
| **Data Type:** ``TDocument``
229228

230229
* - ``collation``
231-
- | *Optional.* The language collation to use when sorting results. See
232-
the :manual:`{+mdb-server+} manual</reference/command/delete/#std-label-deletes-array-collation>`
233-
for more information.
230+
- | *Optional.* The language collation to use when sorting results. See the
231+
:ref:`<csharp-bulk-write-collation>` section of this page for more information.
234232
|
235233
| **Data Type:** `Collation <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Collation.html>`__
236234
| **Default:** ``null``
@@ -298,9 +296,8 @@ parameters:
298296
| **Data Type:** `FilterDefinition<TDocument> <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.FilterDefinition-1.html>`__
299297

300298
* - ``collation``
301-
- | *Optional.* The language collation to use when sorting results. See
302-
the :manual:`{+mdb-server+} manual</reference/command/delete/#std-label-deletes-array-collation>`
303-
for more information.
299+
- | *Optional.* The language collation to use when sorting results. See the
300+
:ref:`<csharp-bulk-write-collation>` section of this page for more information.
304301
|
305302
| **Data Type:** `Collation <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Collation.html>`__
306303
| **Default:** ``null``
@@ -470,6 +467,13 @@ a delete operation:
470467
:copyable:
471468
:dedent: 8
472469

470+
.. _csharp-bulk-write-collation:
471+
472+
Collation
473+
~~~~~~~~~
474+
475+
.. include:: /includes/collation.rst
476+
473477
Return Value
474478
------------
475479

source/crud/delete.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ following properties:
139139

140140
* - ``Collation``
141141
- | Gets or sets the type of language collation to use when sorting
142-
results. See :manual:`the delete
143-
statements</reference/command/delete/#std-label-deletes-array-collation>`
144-
for more information.
142+
results. See the :ref:`<csharp-delete-collation>` section of this page for more
143+
information.
145144

146145
* - ``Comment``
147146
- | Gets or sets the comment for the operation. See :manual:`the delete command
@@ -158,6 +157,13 @@ following properties:
158157
fields</reference/command/delete/#command-fields>`
159158
for more information.
160159

160+
.. _csharp-delete-collation:
161+
162+
Collation
163+
~~~~~~~~~
164+
165+
.. include:: /includes/collation.rst
166+
161167
Example
162168
~~~~~~~
163169

source/crud/query/count.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ You can set the following properties in a ``CountOptions`` object:
9898
- Description
9999

100100
* - ``Collation``
101-
- | The type of language collation to use when sorting results.
101+
- | The type of language collation to use when sorting results. See the
102+
:ref:`<csharp-count-collation>` section of this page for more information.
102103
| Default: ``null``
103104

104105
* - ``Hint``
@@ -132,6 +133,13 @@ You can set the following properties in a ``CountOptions`` object:
132133
CountOptions opts = new CountOptions(){Hint = "_id_"};
133134
var count = collection.CountDocuments(filter, opts);
134135

136+
.. _csharp-count-collation:
137+
138+
Collation
139+
~~~~~~~~~
140+
141+
.. include:: /includes/collation.rst
142+
135143
.. _csharp-estimated-count:
136144

137145
Estimated Count

source/crud/query/distinct.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ describes the properties you can set on a ``DistinctOptions`` instance:
180180
- Description
181181

182182
* - ``Collation``
183-
- | Sets the collation to use for the operation.
183+
- | Sets the collation to use for the operation. See the
184+
:ref:`<csharp-distinct-collation>` section of this page for more information.
185+
| Default: ``null``
184186
| **Data type**: `Collation <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.DistinctOptions.Collation.html>`__
185187

186188
* - ``MaxTime``
@@ -249,6 +251,13 @@ corresponding code.
249251
Angie'S Cafe Pizza
250252
...
251253

254+
.. _csharp-distinct-collation:
255+
256+
Collation
257+
~~~~~~~~~
258+
259+
.. include:: /includes/collation.rst
260+
252261
API Documentation
253262
-----------------
254263

source/crud/query/find.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ You can configure the commonly used options with the following methods:
208208
- | Gets or sets the number of documents to hold in a cursor at a given time.
209209

210210
* - ``Collation``
211-
- | Sets the collation options.
211+
- | Sets the collation options. See the
212+
:ref:`<csharp-find-collation>` section of this page for more information.
212213

213214
* - ``Comment``
214215
- | Sets the comment to the query. To learn more about query comments,
@@ -223,6 +224,13 @@ You can configure the commonly used options with the following methods:
223224
To see a full list of available options, see
224225
`FindOptions Properties <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.FindOptions.html>`__.
225226

227+
.. _csharp-find-collation:
228+
229+
Collation
230+
~~~~~~~~~
231+
232+
.. include:: /includes/collation.rst
233+
226234
Example
227235
~~~~~~~
228236

source/crud/replace.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ The ``ReplaceOptions`` class contains the following properties:
138138

139139
* - ``Collation``
140140
- Specifies the kind of language collation to use when sorting
141-
results. See :manual:`the {+mdb-server+} manual </reference/collation/#std-label-collation>`
142-
for more information on collation.
141+
results. See the :ref:`<csharp-replace-collation>` section of this page for more
142+
information.
143143

144144
**Data Type:** `Collation <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Collation.html>`__
145145

@@ -199,6 +199,13 @@ code.
199199
:start-after: // start-replace-one-async-with-options
200200
:end-before: // end-replace-one-async-with-options
201201

202+
.. _csharp-replace-collation:
203+
204+
Collation
205+
~~~~~~~~~
206+
207+
.. include:: /includes/collation.rst
208+
202209
Return Value
203210
~~~~~~~~~~~~
204211

source/includes/collation.rst

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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.

source/includes/page-templates/update/update.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ The ``UpdateOptions`` class contains the following properties:
165165

166166
* - ``Collation``
167167
- Specifies the kind of language collation to use when sorting
168-
results. See :manual:`the {+mdb-server+} manual</reference/collation/#std-label-collation>`
169-
for more information on collation.
168+
results. See the
169+
:ref:`<csharp-find-collation>` section of this page for more information.
170170

171171
**Data Type:** `Collation <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Collation.html>`__
172172

@@ -199,6 +199,13 @@ The ``UpdateOptions`` class contains the following properties:
199199

200200
**Data Type:** `BsonDocument <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonDocument.html>`__
201201

202+
.. _csharp-update-collation:
203+
204+
Collation
205+
~~~~~~~~~
206+
207+
.. include:: /includes/collation.rst
208+
202209
Return Value
203210
------------
204211

source/logging-and-monitoring/change-streams.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,19 @@ of ``Watch()`` and ``WatchAsync()``:
289289
response from the MongoDB cluster.
290290

291291
* - ``Collation``
292-
- | Specifies the collation to use for the change stream cursor.
292+
- | Specifies the collation to use for the change stream cursor. See the
293+
:ref:`<csharp-change-stream-collation>` section of this page for more information.
293294

294295
* - ``Comment``
295296
- | Attaches a comment to the operation.
296297

298+
.. _csharp-change-stream-collation:
299+
300+
Collation
301+
~~~~~~~~~
302+
303+
.. include:: /includes/collation.rst
304+
297305
.. _csharp-change-stream-pre-post-image:
298306

299307
Include Pre-Images and Post-Images

0 commit comments

Comments
 (0)