Migrate from Elasticsearch 8 to 9 (API renames, transport-agnostic)
Recipe ID
io.moderne.elastic.elastic9.MigrateToElasticsearch9CoreArtifactio.moderne.recipe:rewrite-elasticThe transport-agnostic portion of the Elasticsearch 8 to 9 migration — API renames, field renames, numeric type changes, and removed-class comments. Used as a building block by io.moderne.elastic.elastic9.MigrateToElasticsearch9 and io.moderne.elastic.elastic9.MigrateToElasticsearch9LegacyTransport.
Composite recipeelasticsearchmigrationProprietary
Add to your build
Get a download tokenThis recipe is Moderne licensed, so the token must belong to a Moderne customer. It replaces YOUR_DOWNLOAD_TOKEN below.
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("io.moderne.elastic.elastic9.MigrateToElasticsearch9Core")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("io.moderne.recipe:rewrite-elastic:0.9.0")
}
Then run
./gradlew rewriteRunUsage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe io.moderne.elastic.elastic9.MigrateToElasticsearch9CoreIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:rewrite-elastic:RELEASEDefinition
This recipe runs the following recipes in order.
- Upgrade Gradle or Maven dependency versions
org.openrewrite.java.dependencies.UpgradeDependencyVersion - Change type
elasticsearch.esql.query.EsqlFormattoelasticsearch.esql.EsqlFormatorg.openrewrite.java.ChangeType - Change type
MultisearchBodytoSearchRequestBodyorg.openrewrite.java.ChangeType - Rename API fields for Elasticsearch 9
io.moderne.elastic.elastic9.RenameApiFields - Change numeric field types for Elasticsearch 9
io.moderne.elastic.elastic9.ChangeApiNumericFieldTypes - Use NamedValue parameters instead of Map
io.moderne.elastic.elastic9.UseNamedValueParameters - Migrate script source from String to Script/ScriptSource
io.moderne.elastic.elastic9.MigrateScriptSource - Migrate
matchedQueriesfrom List to Mapio.moderne.elastic.elastic9.MigrateMatchedQueries - Migrate
SpanTermQuery.value()from String to FieldValueio.moderne.elastic.elastic9.MigrateSpanTermQueryValue - Migrate DenseVectorProperty.elementType from String to DenseVectorElementType enum
io.moderne.elastic.elastic9.MigrateDenseVectorElementType - Migrate DenseVectorProperty.similarity from String to DenseVectorSimilarity enum
io.moderne.elastic.elastic9.MigrateDenseVectorSimilarity - Add comment to import statement matching
co.elastic.clients.elasticsearch._types.analysis.LanguageAnalyzerorg.openrewrite.java.AddCommentToImport - Add comment to import statement matching
co.elastic.clients.elasticsearch.nodes.NodeReloadErrororg.openrewrite.java.AddCommentToImport - Add comment to import statement matching
co.elastic.clients.elasticsearch.search_application.list.SearchApplicationListItemorg.openrewrite.java.AddCommentToImport - Add comment to import statement matching
co.elastic.clients.elasticsearch.inference.InferenceRequestorg.openrewrite.java.AddCommentToImport - Add comment to import statement matching
co.elastic.clients.elasticsearch.inference.InferenceResponseorg.openrewrite.java.AddCommentToImport - Add comment to import statement matching
co.elastic.clients.elasticsearch.inference.InferenceResultorg.openrewrite.java.AddCommentToImport - Add comment to import statement matching
co.elastic.clients.elasticsearch.inference.InferenceResultVariantorg.openrewrite.java.AddCommentToImport
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats