@@ -13,7 +13,7 @@ Index Intersection
13
13
.. important::
14
14
15
15
This page documents cases where the :doc:`query optimizer
16
- </core/query-plans>` **may** be able to use index intersection.
16
+ </core/query-plans>` **may** be able to use index intersection.
17
17
18
18
In practice, the :doc:`query optimizer </core/query-plans>` rarely
19
19
selects plans that use index intersection.
@@ -24,7 +24,7 @@ Index Intersection
24
24
25
25
Schema designs should not rely on index intersection. Instead,
26
26
:doc:`compound indexes </core/index-compound>` should be used.
27
-
27
+
28
28
Future improvements to the query optimizer may allow the system to
29
29
better identify cases where an index intersection plan would be
30
30
beneficial.
@@ -89,7 +89,13 @@ index) and the sort order (i.e. ascending or descending), matter in
89
89
:doc:`compound indexes </core/index-compound>`, a compound index may
90
90
not support a query condition that does not include the :ref:`index
91
91
prefix keys <compound-index-prefix>` or that specifies a different sort
92
- order.
92
+ order.
93
+
94
+ .. note::
95
+
96
+ For deployments hosted on MongoDB Atlas, consider using
97
+ :ref:`Atlas Search indexes <index-intersection-search>`
98
+ to avoid limitations due to field order.
93
99
94
100
For example, if a collection ``orders`` has the following compound
95
101
index, with the ``status`` field listed before the ``ord_date`` field:
@@ -171,3 +177,33 @@ part of the query predicate.
171
177
.. code-block:: javascript
172
178
173
179
db.orders.find( { qty: { $gt: 10 } , status: "A" } ).sort( { ord_date: -1 } )
180
+
181
+ .. _index-intersection-search:
182
+
183
+ Index Intersection and Atlas Search Indexes
184
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185
+
186
+ If you use MongoDB Atlas, you can create an Atlas Search index to
187
+ fulfill queries when the query optimizer selects a plan that involves
188
+ index intersection. Unlike :ref:`compound indexes
189
+ <index-intersection-compound-indexes>`, fields in Atlas Search indexes
190
+ can be defined in any order. As a result, the Atlas Seach index can
191
+ support queries that:
192
+
193
+ - Specify a different sort order than the index sort order.
194
+ - Contain fields that are not part of the :ref:`index prefix
195
+ <compound-index-prefix>`.
196
+
197
+ For a tutorial on using Atlas Search indexes when index
198
+ intersection is required, see `Flexible Querying with Atlas Search
199
+ <https://www.mongodb.com/developer/products/atlas/flexible-querying-with-atlas-search/>`__.
200
+
201
+ .. note::
202
+
203
+ Atlas Search Indexes are only available for MongoDB Atlas clusters,
204
+ and is not available for self-managed deployments. To
205
+ learn more, see:
206
+
207
+ - :atlas:`Atlas Search Overview </atlas-search/>`
208
+ - :atlas:`Atlas Search Index Definitions </reference/atlas-search/index-definitions/>`
209
+
0 commit comments