2121using Microsoft . EntityFrameworkCore . Storage ;
2222using MongoDB . Driver ;
2323using MongoDB . EntityFrameworkCore . Metadata ;
24+ using MongoDB . EntityFrameworkCore . Metadata . Search ;
25+ using MongoDB . EntityFrameworkCore . Metadata . Search . Definitions ;
2426using MongoDB . EntityFrameworkCore . Storage ;
2527
2628// ReSharper disable once CheckNamespace
@@ -34,7 +36,8 @@ public static class MongoDatabaseFacadeExtensions
3436{
3537 /// <summary>
3638 /// Creates an index in MongoDB based on the EF Core <see cref="IIndex"/> definition. No attempt is made to check that the index
37- /// does not already exist and can therefore be created. The index may be an Atlas index or a normal MongoDB index.
39+ /// does not already exist and can therefore be created. The index may be a MongoDB search index, MongoDB vector search index,
40+ /// or a normal MongoDB index.
3841 /// </summary>
3942 /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
4043 /// <param name="index">The <see cref="IIndex"/> definition.</param>
@@ -47,7 +50,8 @@ public static void CreateIndex(this DatabaseFacade databaseFacade, IIndex index)
4750
4851 /// <summary>
4952 /// Creates an index in MongoDB based on the EF Core <see cref="IIndex"/> definition. No attempt is made to check that the index
50- /// does not already exist and can therefore be created. The index may be an Atlas index or a normal MongoDB index.
53+ /// does not already exist and can therefore be created. The index may be a MongoDB search index, MongoDB vector index, or a
54+ /// normal MongoDB index.
5155 /// </summary>
5256 /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
5357 /// <param name="index">The <see cref="IIndex"/> definition.</param>
@@ -62,14 +66,14 @@ public static Task CreateIndexAsync(this DatabaseFacade databaseFacade, IIndex i
6266
6367 /// <summary>
6468 /// Creates indexes in the MongoDB database for all <see cref="IIndex"/> definitions in the EF Core model for which there
65- /// is not already an index in the database. This method only creates regular, non-Atlas indexes.
69+ /// is not already an index in the database. This method only creates regular, non-search and non-vector search indexes.
6670 /// </summary>
6771 /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
6872 public static void CreateMissingIndexes ( this DatabaseFacade databaseFacade )
6973 => GetDatabaseCreator ( databaseFacade ) . CreateMissingIndexes ( ) ;
7074
7175 /// <summary>
72- /// Creates missing Atlas vector indexes in the MongoDB database for all <see cref="IIndex"/> definitions in the EF Core model for
76+ /// Creates missing MongoDB vector indexes in the MongoDB database for all <see cref="IIndex"/> definitions in the EF Core model for
7377 /// which there is not already an index in the database.
7478 /// </summary>
7579 /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
@@ -78,7 +82,7 @@ public static void CreateMissingVectorIndexes(this DatabaseFacade databaseFacade
7882
7983 /// <summary>
8084 /// Creates indexes in the MongoDB database for all <see cref="IIndex"/> definitions in the EF Core model for which there
81- /// is not already an index in the database. This method only creates regular, non-Atlas indexes.
85+ /// is not already an index in the database. This method only creates regular, non-search and non-vector search indexes.
8286 /// </summary>
8387 /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
8488 /// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel this asynchronous request.</param>
@@ -87,7 +91,7 @@ public static Task CreateMissingIndexesAsync(this DatabaseFacade databaseFacade,
8791 => GetDatabaseCreator ( databaseFacade ) . CreateMissingIndexesAsync ( cancellationToken ) ;
8892
8993 /// <summary>
90- /// Creates missing Atlas vector indexes in the MongoDB database for all <see cref="IIndex"/> definitions in the EF Core model for
94+ /// Creates missing MongoDB vector indexes in the MongoDB database for all <see cref="IIndex"/> definitions in the EF Core model for
9195 /// which there is not already an index in the database.
9296 /// </summary>
9397 /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
@@ -118,6 +122,46 @@ public static void WaitForVectorIndexes(this DatabaseFacade databaseFacade, Time
118122 public static Task WaitForVectorIndexesAsync ( this DatabaseFacade databaseFacade , TimeSpan ? timeout = null , CancellationToken cancellationToken = default )
119123 => GetDatabaseCreator ( databaseFacade ) . WaitForVectorIndexesAsync ( timeout , cancellationToken ) ;
120124
125+ /// <summary>
126+ /// Creates missing MongoDB search indexes in the MongoDB database for all <see cref="IIndex"/> definitions in the EF Core model for
127+ /// which there is not already an index in the database.
128+ /// </summary>
129+ /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
130+ public static void CreateMissingSearchIndexes ( this DatabaseFacade databaseFacade )
131+ => GetDatabaseCreator ( databaseFacade ) . CreateMissingSearchIndexes ( ) ;
132+
133+ /// <summary>
134+ /// Creates missing MongoDB search indexes in the MongoDB database for all <see cref="SearchIndexDefinition"/> definitions in
135+ /// the EF Core model for which there is not already an index in the database.
136+ /// </summary>
137+ /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
138+ /// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel this asynchronous request.</param>
139+ /// <returns>A <see cref="Task"/> to track this async operation.</returns>
140+ public static Task CreateMissingSearchIndexesAsync ( this DatabaseFacade databaseFacade , CancellationToken cancellationToken = default )
141+ => GetDatabaseCreator ( databaseFacade ) . CreateMissingSearchIndexesAsync ( cancellationToken ) ;
142+
143+ /// <summary>
144+ /// Blocks until all search indexes in the mapped collections are reporting the 'READY' state.
145+ /// </summary>
146+ /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
147+ /// <param name="timeout">The minimum amount of time to wait for all indexes to be 'READY' before aborting.
148+ /// The default is 60 seconds. Zero seconds means no timeout.</param>
149+ /// <exception cref="InvalidOperationException">if the timeout expires before all indexes are 'READY'.</exception>
150+ public static void WaitForSearchIndexes ( this DatabaseFacade databaseFacade , TimeSpan ? timeout = null )
151+ => GetDatabaseCreator ( databaseFacade ) . WaitForSearchIndexes ( timeout ) ;
152+
153+ /// <summary>
154+ /// Blocks until all search indexes in the mapped collections are reporting the 'READY' state.
155+ /// </summary>
156+ /// <param name="databaseFacade">The <see cref="DatabaseFacade"/> from the EF Core <see cref="Microsoft.EntityFrameworkCore.DbContext"/>.</param>
157+ /// <param name="timeout">The minimum amount of time to wait for all indexes to be 'READY' before aborting.
158+ /// The default is 60 seconds. Zero seconds means no timeout.</param>
159+ /// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel this asynchronous request.</param>
160+ /// <returns>A <see cref="Task"/> to track this async operation.</returns>
161+ /// <exception cref="InvalidOperationException">if the timeout expires before all indexes are 'READY'.</exception>
162+ public static Task WaitForSearchIndexesAsync ( this DatabaseFacade databaseFacade , TimeSpan ? timeout = null , CancellationToken cancellationToken = default )
163+ => GetDatabaseCreator ( databaseFacade ) . WaitForSearchIndexesAsync ( timeout , cancellationToken ) ;
164+
121165 /// <summary>
122166 /// Ensures that the database for the context exists. If it exists, no action is taken. If it does not
123167 /// exist then the MongoDB database is created using the <see cref="MongoDatabaseCreationOptions"/> to determine what
0 commit comments