@@ -1448,6 +1448,7 @@ type indexSpec struct {
1448
1448
LanguageOverride string `bson:"language_override,omitempty"`
1449
1449
TextIndexVersion int `bson:"textIndexVersion,omitempty"`
1450
1450
PartialFilterExpression bson.M `bson:"partialFilterExpression,omitempty"`
1451
+ Hidden bool `bson:"hidden,omitempty"`
1451
1452
1452
1453
Collation * Collation `bson:"collation,omitempty"`
1453
1454
}
@@ -1473,6 +1474,9 @@ type Index struct {
1473
1474
// computed by EnsureIndex based on the index key.
1474
1475
Name string
1475
1476
1477
+ // Whether index is hidden from query planner
1478
+ Hidden bool
1479
+
1476
1480
// Properties for spatial indexes.
1477
1481
//
1478
1482
// Min and Max were improperly typed as int when they should have been
@@ -1750,6 +1754,7 @@ func (c *Collection) EnsureIndex(index Index) error {
1750
1754
LanguageOverride : index .LanguageOverride ,
1751
1755
Collation : index .Collation ,
1752
1756
PartialFilterExpression : index .PartialFilter ,
1757
+ Hidden : index .Hidden ,
1753
1758
}
1754
1759
1755
1760
if spec .Min == 0 && spec .Max == 0 {
@@ -1976,6 +1981,7 @@ func indexFromSpec(spec indexSpec) Index {
1976
1981
ExpireAfter : time .Duration (spec .ExpireAfter ) * time .Second ,
1977
1982
Collation : spec .Collation ,
1978
1983
PartialFilter : spec .PartialFilterExpression ,
1984
+ Hidden : spec .Hidden ,
1979
1985
}
1980
1986
if float64 (int (spec .Min )) == spec .Min && float64 (int (spec .Max )) == spec .Max {
1981
1987
index .Min = int (spec .Min )
0 commit comments