1313using Raven . Client . Exceptions ;
1414using Raven . Client . ServerWide ;
1515using Raven . Client . ServerWide . Operations ;
16- using Raven . Client . ServerWide . Operations . Configuration ;
1716using Indexes ;
1817using ServiceControl . RavenDB ;
1918using SagaAudit ;
@@ -24,8 +23,6 @@ public async Task Execute(IDocumentStore documentStore, CancellationToken cancel
2423 {
2524 await CreateDatabase ( documentStore , configuration . Name , cancellationToken ) ;
2625
27- await UpdateDatabaseSettings ( documentStore , configuration . Name , cancellationToken ) ;
28-
2926 await CreateIndexes ( documentStore , configuration . EnableFullTextSearch , cancellationToken ) ;
3027
3128 await StartupChecks . WarnIfIndexesUseCorax ( documentStore , configuration . Name , cancellationToken ) ;
@@ -45,8 +42,10 @@ async Task CreateDatabase(IDocumentStore documentStore, string databaseName, Can
4542 var databaseRecord = new DatabaseRecord ( databaseName ) ;
4643
4744 // New databases use Lucene: smaller indexes, lower memory usage and faster for our index definitions.
48- // Existing databases keep the engine they were created with, see UpdateDatabaseSettings.
49- SetSearchEngineType ( databaseRecord , SearchEngineType . Lucene ) ;
45+ // The settings of an existing database are left to the operator. An index keeps the engine it was
46+ // built with until it is rebuilt, so the database default does not change existing indexes.
47+ databaseRecord . Settings [ "Indexing.Auto.SearchEngineType" ] = nameof ( SearchEngineType . Lucene ) ;
48+ databaseRecord . Settings [ "Indexing.Static.SearchEngineType" ] = nameof ( SearchEngineType . Lucene ) ;
5049
5150 await documentStore . Maintenance . Server . SendAsync ( new CreateDatabaseOperation ( databaseRecord ) , cancellationToken ) ;
5251 }
@@ -57,23 +56,6 @@ async Task CreateDatabase(IDocumentStore documentStore, string databaseName, Can
5756 }
5857 }
5958
60- async Task UpdateDatabaseSettings ( IDocumentStore documentStore , string databaseName , CancellationToken cancellationToken )
61- {
62- var databaseRecord = await documentStore . Maintenance . Server . SendAsync ( new GetDatabaseRecordOperation ( databaseName ) , cancellationToken ) ?? throw new InvalidOperationException ( $ "Database '{ databaseName } ' does not exist.") ;
63-
64- // Existing databases keep their configured search engine. Changing it would trigger a full rebuild of all
65- // indexes, which can take a long time and a lot of resources on large databases. Databases created before the
66- // search engine was pinned explicitly get Corax, which was the default at the time.
67- if ( ! SetSearchEngineType ( databaseRecord , SearchEngineType . Corax ) )
68- {
69- return ;
70- }
71-
72- await documentStore . Maintenance . ForDatabase ( databaseName ) . SendAsync ( new PutDatabaseSettingsOperation ( databaseName , databaseRecord . Settings ) , cancellationToken ) ;
73- await documentStore . Maintenance . Server . SendAsync ( new ToggleDatabasesStateOperation ( databaseName , true ) , cancellationToken ) ;
74- await documentStore . Maintenance . Server . SendAsync ( new ToggleDatabasesStateOperation ( databaseName , false ) , cancellationToken ) ;
75- }
76-
7759 public static async Task DeleteLegacySagaDetailsIndex ( IDocumentStore documentStore , CancellationToken cancellationToken = default )
7860 {
7961 // If the SagaDetailsIndex exists but does not have a .Take(50000), then we remove the current SagaDetailsIndex and
@@ -121,16 +103,6 @@ async Task ConfigureExpiration(IDocumentStore documentStore, CancellationToken c
121103 await documentStore . Maintenance . SendAsync ( new ConfigureExpirationOperation ( expirationConfig ) , cancellationToken ) ;
122104 }
123105
124- bool SetSearchEngineType ( DatabaseRecord database , SearchEngineType searchEngineType )
125- {
126- var updated = false ;
127-
128- updated |= database . Settings . TryAdd ( "Indexing.Auto.SearchEngineType" , searchEngineType . ToString ( ) ) ;
129- updated |= database . Settings . TryAdd ( "Indexing.Static.SearchEngineType" , searchEngineType . ToString ( ) ) ;
130-
131- return updated ;
132- }
133-
134106 internal const string MessagesViewIndexWithFulltextSearchName = "MessagesViewIndexWithFullTextSearch" ;
135107 internal const string SagaDetailsIndexName = "SagaDetailsIndex" ;
136108 internal const string MessagesViewIndexName = "MessagesViewIndex" ;
0 commit comments