@@ -70,7 +70,7 @@ func TestSearchIndexProse(t *testing.T) {
7070 if name == searchName && queryable {
7171 doc = cursor .Current
7272 } else {
73- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
73+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
7474 time .Sleep (5 * time .Second )
7575 }
7676 }
@@ -127,7 +127,7 @@ func TestSearchIndexProse(t *testing.T) {
127127 if name == * args .Name && queryable {
128128 return cursor .Current
129129 }
130- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
130+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
131131 time .Sleep (5 * time .Second )
132132 }
133133 }
@@ -186,7 +186,7 @@ func TestSearchIndexProse(t *testing.T) {
186186 if name == searchName && queryable {
187187 doc = cursor .Current
188188 } else {
189- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
189+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
190190 time .Sleep (5 * time .Second )
191191 }
192192 }
@@ -201,7 +201,7 @@ func TestSearchIndexProse(t *testing.T) {
201201 if ! cursor .Next (ctx ) {
202202 break
203203 }
204- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
204+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
205205 time .Sleep (5 * time .Second )
206206 }
207207 })
@@ -237,7 +237,7 @@ func TestSearchIndexProse(t *testing.T) {
237237 if name == searchName && queryable {
238238 doc = cursor .Current
239239 } else {
240- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
240+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
241241 time .Sleep (5 * time .Second )
242242 }
243243 }
@@ -262,7 +262,7 @@ func TestSearchIndexProse(t *testing.T) {
262262 if name == searchName && queryable && status == "READY" && bytes .Equal (latestDefinition , expected ) {
263263 doc = cursor .Current
264264 } else {
265- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
265+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
266266 time .Sleep (5 * time .Second )
267267 }
268268 }
@@ -315,7 +315,7 @@ func TestSearchIndexProse(t *testing.T) {
315315 if name == searchName && queryable {
316316 doc = cursor .Current
317317 } else {
318- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
318+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
319319 time .Sleep (5 * time .Second )
320320 }
321321 }
@@ -363,7 +363,7 @@ func TestSearchIndexProse(t *testing.T) {
363363 doc = cursor .Current
364364 assert .Equal (mt , indexType , "search" )
365365 } else {
366- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
366+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
367367 time .Sleep (5 * time .Second )
368368 }
369369 }
@@ -391,7 +391,7 @@ func TestSearchIndexProse(t *testing.T) {
391391 doc = cursor .Current
392392 assert .Equal (mt , indexType , "search" )
393393 } else {
394- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
394+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
395395 time .Sleep (5 * time .Second )
396396 }
397397 }
@@ -432,7 +432,7 @@ func TestSearchIndexProse(t *testing.T) {
432432 doc = cursor .Current
433433 assert .Equal (mt , indexType , "vectorSearch" )
434434 } else {
435- t .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
435+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
436436 time .Sleep (5 * time .Second )
437437 }
438438 }
@@ -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 (mt , "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+ require .Equal (mt , indexType , "search" )
508+ } else {
509+ mt .Logf ("cursor: %s, sleep 5 seconds..." , cursor .Current .String ())
510+ time .Sleep (5 * time .Second )
511+ }
512+ }
513+ })
475514}
0 commit comments