Getting Started
Get Metalastic running in your project in 5 minutes.
Prerequisites
- Kotlin 2.2.21+
- Gradle 8.0+
- Spring Data Elasticsearch project
Step 1: Add Dependencies
kotlin
plugins {
id("com.google.devtools.ksp") version "2.3.3"
id("com.ekino.oss.metalastic") version "1.1.0"
}
metalastic {
metamodels {
packageName = "com.example.search"
className = "Metamodels"
classPrefix = "Meta" // Default
}
}kotlin
plugins {
id("com.google.devtools.ksp") version "2.3.3"
}
dependencies {
implementation("com.ekino.oss:metalastic-core:1.1.0")
ksp("com.ekino.oss:metalastic-processor:1.1.0")
}
ksp {
arg("metamodels.package", "com.example.search")
arg("metamodels.className", "Metamodels")
arg("metamodels.classPrefix", "Meta")
}The Gradle plugin provides a type-safe DSL and automatic KSP configuration.
Step 2: Build
bash
./gradlew buildThat's it! Your metamodels are now generated in build/generated/ksp/main/kotlin/.
What's Generated?
For each @Document annotated class, Metalastic generates:
- Metamodel class with type-safe field accessors
- Centralized registry in the
Metamodelsobject - Path traversal support for nested objects
Example
kotlin
import com.example.MetaProduct.Companion.product
// Type-safe field access
product.title.path() // "title"
product.price.path() // "price"
// Nested paths
product.category.name.path() // "category.name"Next Steps
- Configure field types
- Explore the Query DSL
- Learn about path traversal
