@@ -472,4 +472,43 @@ func TestSearchIndexProse(t *testing.T) {
472472 })
473473 assert .ErrorContains (mt , err , "Attribute mappings missing" )
474474 })
475+
476+ mt .Run ("case 9: Drivers use server default for unspecified name (`default`) and type (`search`)" , func (mt * mtest.T ) {
477+ ctx := context .Background ()
478+
479+ view := mt .Coll .SearchIndexes ()
480+ definition := bson.D {
481+ {"mappings" , bson.D {
482+ {"dynamic" , true },
483+ }},
484+ }
485+ opts := options .SearchIndexes ()
486+
487+ indexName , err := view .CreateOne (ctx , mongo.SearchIndexModel {
488+ Definition : definition ,
489+ Options : opts ,
490+ })
491+ require .NoError (mt , err , "failed to create index" )
492+ require .Equal (t , "default" , indexName )
493+
494+ var doc bson.Raw
495+ for doc == nil {
496+ cursor , err := view .List (ctx , opts )
497+ require .NoError (mt , err , "failed to list" )
498+
499+ if ! cursor .Next (ctx ) {
500+ break
501+ }
502+ name := cursor .Current .Lookup ("name" ).StringValue ()
503+ queryable := cursor .Current .Lookup ("queryable" ).Boolean ()
504+ indexType := cursor .Current .Lookup ("type" ).StringValue ()
505+ if name == indexName && queryable {
506+ doc = cursor .Current
507+ assert .Equal (mt , indexType , "search" )
508+ } else {
509+ t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
510+ time .Sleep (5 * time .Second )
511+ }
512+ }
513+ })
475514}
0 commit comments