Skip to content

Commit 9318da7

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-15476 secondary indexes on time series metrics (#253)
* DOCSP-15476 secondary indexes on time series metrics * DOCSP-15476 secondary indexes on time series metrics * DOCSP-15476-secondary-indexes-on-time-series-metrics * DOCSP-15476-secondary-indexes-on-time-series-metrics * DOCSP-15476-secondary-indexes-on-time-series-metrics * DOCSP-15476-secondary-indexes-on-time-series-metrics * DOCSP-15476-secondary-indexes-on-time-series-metrics * DOCSP-15476-secondary-indexes-on-time-series-metrics Co-authored-by: jason-price-mongodb <[email protected]>
1 parent 6942454 commit 9318da7

File tree

6 files changed

+106
-40
lines changed

6 files changed

+106
-40
lines changed

source/core/timeseries-collections.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ Other options allowed with the ``timeseries`` option are:
130130

131131
:method:`db.createCollection()` and :dbcommand:`create`.
132132

133+
.. _timeseries-collections-insert:
134+
133135
Insert Measurements into a Time Series Collection
134136
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135137

source/core/timeseries/timeseries-limitations.txt

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. _manual-timeseries-collection-limitations:
22

3-
==================================
4-
Time Series Collection Limitations
5-
==================================
3+
============================================
4+
Time Series Collection Notes and Limitations
5+
============================================
66

77
.. default-domain:: mongodb
88

@@ -59,14 +59,79 @@ To remove all documents from a collection, use the
5959

6060
.. _timeseries-limitations-secondary-indexes:
6161

62-
Secondary Indexes
63-
~~~~~~~~~~~~~~~~~
62+
Time Series Secondary Indexes
63+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6464

6565
You can add :term:`secondary indexes <secondary index>` on the fields
6666
specified as the ``timeField`` and the ``metaField``. If the field value
6767
for the ``metaField`` field is a document, you can also create secondary
6868
indexes on fields inside that document.
6969

70+
The following sections describe:
71+
72+
- Additional secondary indexes you can add.
73+
74+
- Secondary index limitations.
75+
76+
Time Series Secondary Indexes in MongoDB 5.3
77+
````````````````````````````````````````````
78+
79+
Starting in MongoDB 5.3:
80+
81+
- You can add the following secondary indexes to a :ref:`time series
82+
collection <manual-timeseries-collection>`:
83+
84+
- :doc:`Partial
85+
</core/index-partial>`, :doc:`2d </core/2d>`, and :doc:`2dsphere
86+
</core/2dsphere>` indexes to a metadata field.
87+
88+
- :doc:`2dsphere </core/2dsphere>` and :doc:`partial
89+
</core/index-partial>` indexes to a measurement field.
90+
91+
- :doc:`Compound index </core/index-compound>` on time, metadata, or
92+
measurement fields.
93+
94+
- If you need to downgrade the Feature Compatibility Version (FCV),
95+
you must first drop any indexes that are incompatible with the
96+
downgraded FCV. See :dbcommand:`setFeatureCompatibilityVersion`.
97+
98+
- You can use the :query:`$or`, :query:`$in`, and :query:`$geoWithin`
99+
operators with :doc:`partial indexes </core/index-partial>` on a time
100+
series collection.
101+
102+
- You can use the :pipeline:`$geoNear` pipeline operator with a:
103+
104+
.. include:: /includes/geoNear-time-series.rst
105+
106+
For example, the following ``sensorData`` collection contains
107+
temperature readings:
108+
109+
.. code-block:: javascript
110+
111+
db.sensorData.insertMany( [
112+
{
113+
"metadata": { "sensorId": 5578, "type": "temperature" },
114+
"timestamp": ISODate("2022-01-15T00:00:00.000Z"),
115+
"temperatureReading": 12
116+
},
117+
{
118+
"metadata": { "sensorId": 5578, "type": "temperature" },
119+
"timestamp": ISODate("2022-01-15T04:00:00.000Z"),
120+
"temperatureReading": 11
121+
}
122+
] )
123+
124+
The following example creates an ascending secondary index on the
125+
``metadata.sensorId`` and ``temperatureReading`` fields in the
126+
``sensorData`` collection:
127+
128+
.. code-block:: javascript
129+
130+
db.sensorData.createIndex( { "metadata.sensorId": 1, "temperatureReading": 1 } )
131+
132+
Secondary Index Limitations
133+
```````````````````````````
134+
70135
In MongoDB 5.1, the ``metaField`` doesn't support :doc:`text
71136
</core/index-text>` indexes.
72137

@@ -79,9 +144,12 @@ types:
79144

80145
Secondary indexes don't support the following index properties:
81146

147+
- :doc:`2d </core/2d>` in MongoDB 5.2 and lower
148+
- :doc:`2dsphere </core/2dsphere>` in MongoDB 5.2 and lower
82149
- :doc:`TTL </core/index-ttl>`
83150
- :doc:`Unique </core/index-unique>`
84-
- :doc:`Partial </core/index-partial>`
151+
- :doc:`Partial </core/index-partial>` in MongoDB 5.2 and lower
152+
- :doc:`Multikey index </core/index-multikey>` on a measurement field
85153

86154
``reIndex``
87155
~~~~~~~~~~~
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- :doc:`2dsphere </core/2dsphere>` index on a :ref:`time series
2+
collection <manual-timeseries-collection>`.
3+
4+
- Query on any field in a time series collection, including
5+
metadata fields.

source/reference/operator/aggregation/geoNear.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,18 @@ When using :pipeline:`$geoNear`, consider that:
201201

202202
- .. include:: /includes/extracts/views-unsupported-geoNear.rst
203203

204-
- Starting in version 4.2, :pipeline:`$geoNear` no longer has a default
204+
- Starting in MongoDB 4.2, :pipeline:`$geoNear` no longer has a default
205205
limit of 100 documents.
206206

207207
- Starting in MongoDB 5.1, the ``near`` parameter supports the
208208
:ref:`let option <geoNear_let_example>` and
209209
:ref:`bound let option <geoNear_bounded_let_example>`.
210210

211+
- Starting in MongoDB 5.3, you can use the :pipeline:`$geoNear` pipeline
212+
operator with a:
213+
214+
.. include:: /includes/geoNear-time-series.rst
215+
211216
Examples
212217
--------
213218

source/release-notes/5.3-compatibility.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@ Compatibility Changes in MongoDB 5.3
1515
This page is a work in progress and will be updated with changes
1616
introduced in 5.3 that can affect compatibility with older versions of
1717
MongoDB.
18+
19+
Time Series Collections
20+
-----------------------
21+
22+
If there are :term:`secondary indexes <secondary index>` on :ref:`time
23+
series collections <manual-timeseries-collection>` and you need to
24+
downgrade the Feature Compatibility Version (FCV), you must first drop
25+
any secondary indexes that are incompatible with the downgraded FCV. See
26+
:ref:`timeseries-limitations-secondary-indexes`.

source/release-notes/5.3.txt

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,23 @@ Release Notes for MongoDB 5.3
1212

1313
.. include:: /includes/in-dev.rst
1414

15-
.. _5.3-rel-notes-aggregation:
16-
17-
Aggregation
18-
-----------
19-
20-
.. _5.3-rel-notes-new-agg-operators:
21-
22-
New Aggregation Operators
23-
~~~~~~~~~~~~~~~~~~~~~~~~~
24-
25-
MongoDB 5.3 introduces the following aggregation operators:
26-
27-
.. list-table::
28-
:header-rows: 1
29-
:widths: 20 80
30-
31-
* - Operator
32-
- Description
33-
34-
* - <<TBD>>
35-
- <<TBD>>
36-
37-
.. _5.3-rel-notes-sharding:
38-
39-
Sharding
40-
--------
41-
42-
<<TBD>>
43-
4415
.. _5.3-rel-notes-general:
4516

4617
General Improvements
4718
--------------------
4819

49-
<<TBD>>
20+
Time Series Collection Improvements
21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22+
23+
Starting in MongoDB 5.3, you can:
24+
25+
- Add additional :term:`secondary index <secondary index>` types to
26+
:ref:`time series collections <manual-timeseries-collection>`. See
27+
:ref:`timeseries-limitations-secondary-indexes`.
5028

51-
Replica Sets
52-
------------
29+
- Use the :pipeline:`$geoNear` pipeline operator with a:
5330

54-
<<TBD>>
31+
.. include:: /includes/geoNear-time-series.rst
5532

5633
Security
5734
--------

0 commit comments

Comments
 (0)