Skip to content

Commit fd13038

Browse files
authored
INFRA-3688 Support hidden index flag (globalsign#32)
1 parent ca3f4ab commit fd13038

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

session.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,7 @@ type indexSpec struct {
14481448
LanguageOverride string `bson:"language_override,omitempty"`
14491449
TextIndexVersion int `bson:"textIndexVersion,omitempty"`
14501450
PartialFilterExpression bson.M `bson:"partialFilterExpression,omitempty"`
1451+
Hidden bool `bson:"hidden,omitempty"`
14511452

14521453
Collation *Collation `bson:"collation,omitempty"`
14531454
}
@@ -1473,6 +1474,9 @@ type Index struct {
14731474
// computed by EnsureIndex based on the index key.
14741475
Name string
14751476

1477+
// Whether index is hidden from query planner
1478+
Hidden bool
1479+
14761480
// Properties for spatial indexes.
14771481
//
14781482
// Min and Max were improperly typed as int when they should have been
@@ -1750,6 +1754,7 @@ func (c *Collection) EnsureIndex(index Index) error {
17501754
LanguageOverride: index.LanguageOverride,
17511755
Collation: index.Collation,
17521756
PartialFilterExpression: index.PartialFilter,
1757+
Hidden: index.Hidden,
17531758
}
17541759

17551760
if spec.Min == 0 && spec.Max == 0 {
@@ -1976,6 +1981,7 @@ func indexFromSpec(spec indexSpec) Index {
19761981
ExpireAfter: time.Duration(spec.ExpireAfter) * time.Second,
19771982
Collation: spec.Collation,
19781983
PartialFilter: spec.PartialFilterExpression,
1984+
Hidden: spec.Hidden,
19791985
}
19801986
if float64(int(spec.Min)) == spec.Min && float64(int(spec.Max)) == spec.Max {
19811987
index.Min = int(spec.Min)

0 commit comments

Comments
 (0)