Keep the search engine configured on an index when deploying index definitions - #5946
Merged
Merged
Conversation
…finitions Operators migrating indexes from Corax to Lucene in RavenDB Studio store the search engine in the index configuration. ServiceControl deployed its index definitions without it, so RavenDB built a side-by-side replacement that fell back to the database default, which is Corax for databases created before 6.20. Unless the index was locked, every start-up reset migrated indexes back to Corax. Index definitions are now deployed carrying over the search engine configured on the existing index (or on its pending replacement). A migrated index no longer needs to be locked, still receives definition changes, and a pending Corax replacement created by earlier versions is discarded at start-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ramonsmits
reviewed
Oct 5, 2026
ramonsmits
reviewed
Oct 5, 2026
ramonsmits
reviewed
Oct 5, 2026
ramonsmits
reviewed
Oct 5, 2026
Indexes that don't exist on the server yet are now created with the Lucene search engine pinned on the index, also in existing databases that still default to Corax. A search engine set explicitly in an index definition, through SearchEngineType or Configuration, takes precedence over the one on the server. Expand the comments to explain why the search engine has to be resolved before deploying the index definitions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng index definitions
mauroservienti
commented
Oct 5, 2026
ramonsmits
approved these changes
Oct 5, 2026
This was referenced Oct 5, 2026
ramonsmits
added a commit
that referenced
this pull request
Oct 5, 2026
…finitions (#5946) (#5950) * Keep the search engine configured on an index when deploying index definitions Operators migrating indexes from Corax to Lucene in RavenDB Studio store the search engine in the index configuration. ServiceControl deployed its index definitions without it, so RavenDB built a side-by-side replacement that fell back to the database default, which is Corax for databases created before 6.20. Unless the index was locked, every start-up reset migrated indexes back to Corax. Index definitions are now deployed carrying over the search engine configured on the existing index (or on its pending replacement). A migrated index no longer needs to be locked, still receives definition changes, and a pending Corax replacement created by earlier versions is discarded at start-up. ---- * Create new indexes with Lucene and respect search engines set in code Indexes that don't exist on the server yet are now created with the Lucene search engine pinned on the index, also in existing databases that still default to Corax. A search engine set explicitly in an index definition, through SearchEngineType or Configuration, takes precedence over the one on the server. Expand the comments to explain why the search engine has to be resolved before deploying the index definitions. --------- (cherry picked from commit 53e287d) Co-authored-by: Mauro Servienti <mauro.servienti@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Version 6.20.0 recommends the migration of RavenDB indexes from Corax to Lucene. The documented procedure changes the search engine of one index on the Configuration tab in RavenDB Studio. RavenDB stores this choice as
Indexing.Static.SearchEngineTypein the index configuration.At each start-up, ServiceControl deploys its index definitions with
IndexCreation.CreateIndexesAsync. These definitions have no search engine. RavenDB sees a different definition and builds a side-by-sideReplacementOf/<index>with the database default. For databases created before 6.20, the default is Corax, becauseUpdateDatabaseSettingssets it. If the migrated index is not locked, RavenDB resets it to Corax and rebuilds it.A customer unlocked a migrated
MessagesViewIndexWithFullTextSearchbecause the docs said that a lock is not necessary from 6.20.0. The index was reset to Corax.Fix
The new
IndexDeploymenthelper inServiceControl.RavenDBreplacesIndexCreation.CreateIndexesAsyncin the Primary and AuditDatabaseSetup. Before deployment, it reads the existing index definitions and sets the search engine of each index with these rules:SearchEngineTypeorConfiguration, always wins.Effects:
Tests
Audit
IndexSetupTests:Indexes_should_be_reset_on_setuptested the old behavior. Two tests replace it:Search_engine_configured_on_the_index_should_be_preserved_on_setup: no replacement, the index is not recreated.Indexes_should_be_reset_on_setup_keeping_the_configured_search_engine: a changed field is reset, the engine is kept.Pending_replacement_using_the_database_default_should_be_discarded_in_favor_of_the_configured_search_engine: reproduces the state of the customer. Indexing is stopped so that the replacement cannot swap.New_indexes_should_be_created_with_lucene: a deleted index is recreated with Lucene set on it.Search_engine_set_in_the_index_definition_should_take_precedence_over_the_one_on_the_server: coversSearchEngineTypeandConfiguration.Primary
IndexSetupTests(new): covers the assembly scan.Each new Audit test fails without the code that it covers. Both RavenDB persistence suites pass locally: Audit 57/57, Primary 349/349.
Verification with containers
Upgrade paths tested with podman, an external RavenDB container and RabbitMQ. Indexes were migrated in the same way as the Studio does it.
MessagesViewIndexWithFullTextSearchis rebuilt once on Lucene, because its definition changed in 6.20.0 (Remove decommissioned endpoints from usage reports #5670).Related