I'm trying to use an embedded ElasticSearch server for local development. This way it is much easier to create documents on startup, change the documents/fields instead of migrating, and so on.
For MongoDB there's already a solution in Spring Boot by simply adding developmentOnly 'de.flapdoodle.embed:de.flapdoodle.embed.mongo'
to the gradle build file. Everything else is done by EmbeddedMongoAutoConfiguration.
Then I'm creating the documents on startup by using the following class:
@Configuration
@RequiredArgsConstructor
@AutoConfigureAfter(EmbeddedMongoAutoConfiguration.class)
public class EmbeddedMongoDataConfiguration {
private final MyReactiveRepository repository;
@PostConstruct
public void init() {
repository.save(MyDocument.builder().build()).subscribe();
}
}
Now I would like to do the same with ElasticSearch. There's allegro/embedded-elasticsearch. That repository is archived however.
I can't find any similar EmbeddedElasticSearchAutoConfiguration
so I assume that's not possible (yet).
Comment From: snicoll
We tend to rely on Testcontainers for that sort of things, which is what the project you've referenced states already anyway. Elasticsearch used to have an embedded mode and deprecated it so it is very unlikely that Spring Boot would offer that feature in the future.
Check the doc for the elasticsearch container module for more details.
Comment From: dtrunk90
I understand the decision on using test containers instead. But I don't understand why this feature is available for MongoDB then.
Comment From: snicoll
I am not sure what there is to understand.
Spring Boot does not implement those things and there is a third party project for MongoDB that supports this feature. As I've explained, both the project you've referenced and Elasticsearch itself have stopped supporting embedded mode.
Comment From: dtrunk90
Oh sorry, I misread about the deprecated embedded mode of ElasticSearch. Thanks for the clarification.