[SERVER-55239] Support 2dsphere index on time-series collection metadata fields Created: 16/Mar/21  Updated: 02/Sep/21  Resolved: 27/Jul/21

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Dianna Hohensee (Inactive) Assignee: Dan Larkin-York
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-58602 Rewrite $geoNear to $geoWithin + comp... Closed
Duplicate
is duplicated by SERVER-55608 Allow geo queries on time series view... Closed
Related
related to SERVER-54642 Support other index types on the meta... Closed
Sprint: Execution Team 2021-07-12, Execution Team 2021-07-26, Execution Team 2021-08-09
Participants:
Linked BF Score: 70

 Description   

Because metadata does not vary within a bucket, geo indexes on metadata can use an ordinary geo index on the time-series buckets collection.

For example,

{
	createIndexes: “abc”,
	indexes: [ { key: { “metaFieldName.a” : "2dsphere" } } ]
}

will become

{
	createIndexes: “system.buckets.abc”,
	indexes: [ { key: { “meta.a” : "2dsphere" } } ]
}

 

 

 

JS test code

assert.eq(1,
          timeseriescoll.aggregate([
              {$geoNear: {
                  near: {type: "Point", coordinates: [40.4, -70.4]},
                  distanceField: "dist",
                  spherical: true
              }},
              {$limit: 1}
          ]).toArray().length,
          "Failed to use 2dsphere index: " + tojson(twoDSphereBucketsIndexSpec));

JS test logs

[js_test:timeseries_special_indexes] assert: command failed: {
[js_test:timeseries_special_indexes] 	"ok" : 0,
[js_test:timeseries_special_indexes] 	"errmsg" : "$geoNear is only valid as the first stage in a pipeline.",
[js_test:timeseries_special_indexes] 	"code" : 40602,
[js_test:timeseries_special_indexes] 	"codeName" : "Location40602"
[js_test:timeseries_special_indexes] } with original command request: {
[js_test:timeseries_special_indexes] 	"aggregate" : "timeseries_special_indexes_coll",
[js_test:timeseries_special_indexes] 	"pipeline" : [
[js_test:timeseries_special_indexes] 		{
[js_test:timeseries_special_indexes] 			"$geoNear" : {
[js_test:timeseries_special_indexes] 				"near" : {
[js_test:timeseries_special_indexes] 					"type" : "Point",
[js_test:timeseries_special_indexes] 					"coordinates" : [
[js_test:timeseries_special_indexes] 						40.4,
[js_test:timeseries_special_indexes] 						-70.4
[js_test:timeseries_special_indexes] 					]
[js_test:timeseries_special_indexes] 				},
[js_test:timeseries_special_indexes] 				"distanceField" : "dist",
[js_test:timeseries_special_indexes] 				"spherical" : true
[js_test:timeseries_special_indexes] 			}
[js_test:timeseries_special_indexes] 		},
[js_test:timeseries_special_indexes] 		{
[js_test:timeseries_special_indexes] 			"$limit" : 1
[js_test:timeseries_special_indexes] 		}
[js_test:timeseries_special_indexes] 	],
[js_test:timeseries_special_indexes] 	"cursor" : {
[js_test:timeseries_special_indexes]
[js_test:timeseries_special_indexes] 	},
[js_test:timeseries_special_indexes] 	"lsid" : {
[js_test:timeseries_special_indexes] 		"id" : UUID("073e7905-4789-4ab9-88f2-45fb46cb2f97")
[js_test:timeseries_special_indexes] 	}
[js_test:timeseries_special_indexes] } on connection: connection to localhost:50190 : aggregate failed
[js_test:timeseries_special_indexes] _getErrorWithCode@src/mongo/shell/utils.js:25:13
[js_test:timeseries_special_indexes] doassert@src/mongo/shell/assert.js:18:14
[js_test:timeseries_special_indexes] _assertCommandWorked@src/mongo/shell/assert.js:719:17
[js_test:timeseries_special_indexes] assert.commandWorked@src/mongo/shell/assert.js:811:16
[js_test:timeseries_special_indexes] DB.prototype._runAggregate@src/mongo/shell/db.js:268:5
[js_test:timeseries_special_indexes] DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1056:12
[js_test:timeseries_special_indexes] @jstests/core/timeseries/timeseries_special_indexes.js:210:11
[js_test:timeseries_special_indexes] @jstests/core/timeseries/timeseries_special_indexes.js:18:2
[js_test:timeseries_special_indexes] uncaught exception: Error: command failed: {
[js_test:timeseries_special_indexes] 	"ok" : 0,
[js_test:timeseries_special_indexes] 	"errmsg" : "$geoNear is only valid as the first stage in a pipeline.",
[js_test:timeseries_special_indexes] 	"code" : 40602,
[js_test:timeseries_special_indexes] 	"codeName" : "Location40602"
[js_test:timeseries_special_indexes] } with original command request: {
[js_test:timeseries_special_indexes] 	"aggregate" : "timeseries_special_indexes_coll",
[js_test:timeseries_special_indexes] 	"pipeline" : [
[js_test:timeseries_special_indexes] 		{
[js_test:timeseries_special_indexes] 			"$geoNear" : {
[js_test:timeseries_special_indexes] 				"near" : {
[js_test:timeseries_special_indexes] 					"type" : "Point",
[js_test:timeseries_special_indexes] 					"coordinates" : [
[js_test:timeseries_special_indexes] 						40.4,
[js_test:timeseries_special_indexes] 						-70.4
[js_test:timeseries_special_indexes] 					]
[js_test:timeseries_special_indexes] 				},
[js_test:timeseries_special_indexes] 				"distanceField" : "dist",
[js_test:timeseries_special_indexes] 				"spherical" : true
[js_test:timeseries_special_indexes] 			}
[js_test:timeseries_special_indexes] 		},
[js_test:timeseries_special_indexes] 		{
[js_test:timeseries_special_indexes] 			"$limit" : 1
[js_test:timeseries_special_indexes] 		}
[js_test:timeseries_special_indexes] 	],
[js_test:timeseries_special_indexes] 	"cursor" : {
[js_test:timeseries_special_indexes]
[js_test:timeseries_special_indexes] 	},
[js_test:timeseries_special_indexes] 	"lsid" : {
[js_test:timeseries_special_indexes] 		"id" : UUID("073e7905-4789-4ab9-88f2-45fb46cb2f97")
[js_test:timeseries_special_indexes] 	}
[js_test:timeseries_special_indexes] } on connection: connection to localhost:50190 : aggregate failed :
[js_test:timeseries_special_indexes] _getErrorWithCode@src/mongo/shell/utils.js:25:13
[js_test:timeseries_special_indexes] doassert@src/mongo/shell/assert.js:18:14
[js_test:timeseries_special_indexes] _assertCommandWorked@src/mongo/shell/assert.js:719:17
[js_test:timeseries_special_indexes] assert.commandWorked@src/mongo/shell/assert.js:811:16
[js_test:timeseries_special_indexes] DB.prototype._runAggregate@src/mongo/shell/db.js:268:5
[js_test:timeseries_special_indexes] DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1056:12
[js_test:timeseries_special_indexes] @jstests/core/timeseries/timeseries_special_indexes.js:210:11
[js_test:timeseries_special_indexes] @jstests/core/timeseries/timeseries_special_indexes.js:18:2
[js_test:timeseries_special_indexes] failed to load: jstests/core/timeseries/timeseries_special_indexes.js

Note: the same query on the corresponding buckets collection works fine, so the index is created via the time-series collection, we just can't use it.



 Comments   
Comment by Githook User [ 27/Jul/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-55239 Support 2dsphere index on time-series collection metadata fields
Branch: master
https://github.com/mongodb/mongo/commit/8068b7bedaf39a182af31c2c7e0a7f6d992555e9

Comment by Dianna Hohensee (Inactive) [ 22/Mar/21 ]

Closing this out as Won't Do. We do not currently plan to support geo.

Generated at Thu Feb 08 05:35:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.