Skip to content

Commit ffeccb2

Browse files
author
Chris Cho
authored
DOCSP-23294: Queryable Encryption _id Field Limitation (#1279)
1 parent d65d042 commit ffeccb2

File tree

2 files changed

+48
-37
lines changed

2 files changed

+48
-37
lines changed

source/core/queryable-encryption/fundamentals/encrypt-and-query.txt

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ In this guide, you can learn about the following {+qe+} topics:
2222
- Query types and which ones you can use on encrypted fields.
2323
- What to consider when deciding whether to enable queries on an encrypted field.
2424

25-
Specify Fields for Encryption
25+
Specify Fields for Encryption
2626
-----------------------------
2727

28-
{+qe+} allows you to specify which fields you want to automatically
28+
{+qe+} allows you to specify which fields you want to automatically
2929
encrypt in your MongoDB document.
3030

31+
.. important::
32+
33+
You can specify any field in your document for encryption except the
34+
``_id`` field.
35+
3136
To specify fields for encryption and querying, define a JSON
3237
schema that includes the following properties:
3338

@@ -58,10 +63,10 @@ schema that includes the following properties:
5863
Example
5964
~~~~~~~
6065

61-
This example shows how to create a JSON schema that specifies which fields that
66+
This example shows how to create a JSON schema that specifies which fields that
6267
the {+qe+} feature should automatically encrypt.
6368

64-
Consider the following document that contains personally identifiable information
69+
Consider the following document that contains personally identifiable information
6570
(PII), credit card information, and sensitive medical information:
6671

6772
.. code-block:: json
@@ -84,8 +89,8 @@ Consider the following document that contains personally identifiable informatio
8489
}
8590
}
8691

87-
To ensure the PII and sensitive medical information stays secure, create a JSON
88-
schema that configures {+qe+} to automatically encrypt those fields.
92+
To ensure the PII and sensitive medical information stays secure, create a JSON
93+
schema that configures {+qe+} to automatically encrypt those fields.
8994
The following sample JSON schema shows how you can specify which fields to encrypt:
9095

9196
.. code-block:: javascript
@@ -115,24 +120,24 @@ The following sample JSON schema shows how you can specify which fields to encry
115120
]
116121
}
117122

118-
Note that the ``keyId`` field requires a unique {+dek-long+} (DEK) which {+qe+}
119-
uses to encrypt the fields. For more information on DEKs, see
123+
Note that the ``keyId`` field requires a unique {+dek-long+} (DEK) which {+qe+}
124+
uses to encrypt the fields. For more information on DEKs, see
120125
:ref:`qe-fundamentals-manage-keys`.
121126

122127
Specify Queryable Encrypted Fields
123128
----------------------------------
124129

125-
Include the ``queries`` property on fields you want to make queryable in your JSON
126-
schema. This enables an authorized client to issue read and write queries using
127-
encrypted fields. You can omit the ``queries`` property unless you want to be able
130+
Include the ``queries`` property on fields you want to make queryable in your JSON
131+
schema. This enables an authorized client to issue read and write queries using
132+
encrypted fields. You can omit the ``queries`` property unless you want to be able
128133
to query the field.
129134

130135

131136
Example
132137
~~~~~~~
133138

134-
The following code snippet shows how to add the ``queries`` property to the
135-
JSON schema to make the ``patientId`` and ``patientInfo.ssn``
139+
The following code snippet shows how to add the ``queries`` property to the
140+
JSON schema to make the ``patientId`` and ``patientInfo.ssn``
136141
fields queryable..
137142

138143
.. code-block:: javascript
@@ -172,8 +177,8 @@ Enable {+qe+}
172177

173178
You can enable {+qe+} on fields you specify in a JSON schema in the following ways:
174179

175-
- Pass the JSON schema, represented by the ``encryptedFieldsObject`` constant,
176-
to the client that the application uses to create the collection as shown in the
180+
- Pass the JSON schema, represented by the ``encryptedFieldsObject`` constant,
181+
to the client that the application uses to create the collection as shown in the
177182
following code snippet:
178183

179184

@@ -199,14 +204,14 @@ You can enable {+qe+} on fields you specify in a JSON schema in the following wa
199204

200205
.. note::
201206

202-
It's important to enable {+qe+} before creating the collection. Enabling
203-
{+qe+} after creating the collection does not encrypt fields on documents
207+
It's important to enable {+qe+} before creating the collection. Enabling
208+
{+qe+} after creating the collection does not encrypt fields on documents
204209
already in that collection.
205210

206-
For more information on ``autoEncryption`` configuration options, see the
211+
For more information on ``autoEncryption`` configuration options, see the
207212
section on :ref:`qe-reference-mongo-client`.
208213

209-
- Pass the encrypted fields object to your call to create a new collection as
214+
- Pass the encrypted fields object to your call to create a new collection as
210215
shown in the following code snippet:
211216

212217
.. code-block:: javascript
@@ -216,29 +221,29 @@ section on :ref:`qe-reference-mongo-client`.
216221
});
217222

218223
.. tip::
219-
220-
For the highest level of security, specify the encrypted fields both when
221-
creating the collection, and when creating a client to access the collection.
222-
This ensures that if the server's security is compromised, the information
224+
225+
For the highest level of security, specify the encrypted fields both when
226+
creating the collection, and when creating a client to access the collection.
227+
This ensures that if the server's security is compromised, the information
223228
is still encrypted through the client.
224229

225230
.. important::
226231

227-
MongoDB recommends explicitly creating your collection when using {+qe+}, rather
228-
than implicitly creating the collection through an insert operation. When you
229-
create a collection using ``createCollection()``, the operation creates an index
230-
on the encrypted fields. Without an index, querying on encrypted fields could
232+
MongoDB recommends explicitly creating your collection when using {+qe+}, rather
233+
than implicitly creating the collection through an insert operation. When you
234+
create a collection using ``createCollection()``, the operation creates an index
235+
on the encrypted fields. Without an index, querying on encrypted fields could
231236
run slowly.
232237

233238
.. _qe-query-types:
234239

235240
Query Types
236241
-----------
237242

238-
{+qe+} allows you to specify on which fields you want to enable querying by passing
243+
{+qe+} allows you to specify on which fields you want to enable querying by passing
239244
a query type to the ``queries`` option in your encrypted fields object.
240245

241-
{+qe+} supports the ``equality`` query type. The ``equality`` query type allows
246+
{+qe+} supports the ``equality`` query type. The ``equality`` query type allows
242247
you to query encrypted fields using the following expressions:
243248

244249
- :manual:`$eq </reference/operator/query/eq/>`
@@ -252,13 +257,13 @@ you to query encrypted fields using the following expressions:
252257
- :manual:`$expr </reference/operator/query/expr/>`
253258

254259
.. note::
255-
Queries that compare an encrypted field to ``null`` or to a regular expression will
260+
Queries that compare an encrypted field to ``null`` or to a regular expression will
256261
result in an error, even when using a supported query operator.
257262

258263
.. _qe-query-unsupported:
259264

260-
{+qe+} using the ``equality`` query type doesn't support read or write operations
261-
on a field when the operation compares the encrypted field to any of the following
265+
{+qe+} using the ``equality`` query type doesn't support read or write operations
266+
on a field when the operation compares the encrypted field to any of the following
262267
:term:`BSON` types:
263268

264269
- ``double``
@@ -271,13 +276,13 @@ on a field when the operation compares the encrypted field to any of the followi
271276
Considerations when Enabling Querying
272277
-------------------------------------
273278

274-
When you use {+qe+}, you can choose whether to make an encrypted field queryable.
275-
If you don't need to perform read operations, or write operations that require you
276-
to read an encrypted field, you may decide not to enable querying on that field.
279+
When you use {+qe+}, you can choose whether to make an encrypted field queryable.
280+
If you don't need to perform read operations, or write operations that require you
281+
to read an encrypted field, you may decide not to enable querying on that field.
277282
You can still retrieve the entire document by querying other fields that are queryable or not encrypted.
278283

279-
When you make encrypted fields queryable, {+qe+} creates an index for each encrypted field, which
280-
can make write operations on that field take longer. When a write operation updates
284+
When you make encrypted fields queryable, {+qe+} creates an index for each encrypted field, which
285+
can make write operations on that field take longer. When a write operation updates
281286
an indexed field, MongoDB also updates the related index.
282287

283288
When you enable querying on an encrypted field, your collection requires more storage space.

source/core/queryable-encryption/reference/limitations.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ cannot introspect the index catalog to identify a given field as unique.
228228
Applications cannot rely on automatic encryption validation to prevent
229229
unique constraint violations on randomly-encrypted fields.
230230

231+
The _id Field
232+
-------------
233+
234+
You cannot instruct {+qe+} to encrypt the ``_id`` field because it relies on
235+
the value auto-generated by MongoDB.
236+
231237
Read/Write Query Support
232238
------------------------
233239

0 commit comments

Comments
 (0)