Skip to content

Commit

Permalink
(DOCSP-36307): Fix inaccuracy for index on embedded field (#6263)
Browse files Browse the repository at this point in the history
* (DOCSP-36307): Fix inaccuracy for index on embedded field

* tweak

* spacing
  • Loading branch information
jeff-allen-mongo committed Feb 7, 2024
1 parent a320309 commit 8eff978
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ The following query uses the index on the ``location`` field:
Details
```````

When you create an index on an embedded document, only queries that
specify the *entire* embedded document use the index. Queries on a
specific field within the document do not use the index.
.. include:: /includes/indexes/embedded-object-need-entire-doc.rst

For example, the following queries *do not* use the index on the
``location`` field because they query on specific fields within the
Expand Down
3 changes: 3 additions & 0 deletions source/includes/indexes/embedded-object-need-entire-doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When you create an index on an embedded document, only queries that
specify the entire embedded document use the index. Queries on a
specific field within the document do not use the index.
11 changes: 8 additions & 3 deletions source/indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ example, consider the following scenarios:
* - A salesperson often needs to look up client information by
location. Location is stored in an embedded object with fields
like ``state``, ``city``, and ``zipcode``. You can create an
index on the entire ``location`` object to improve performance
for queries on any field in that object.
index on the ``location`` object to improve performance for
queries on that object.

- :ref:`Single Field Index <indexes-single-field>` on an object
.. note::

.. include:: /includes/indexes/embedded-object-need-entire-doc.rst

- :ref:`Single Field Index <indexes-single-field>` on an embedded
document

* - A grocery store manager often needs to look up inventory items by
name and quantity to determine which items are low stock. You can
Expand Down

0 comments on commit 8eff978

Please sign in to comment.