You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reactive save does not apply the custom id conversion #3359
The reactive template does not apply the registered id conversion when it saves an entity, while the reactive read and delete operations do. The imperative template converts the id in all three cases.
AbstractReactiveElasticsearchTemplate.getIndexQuery(Object) sets the id with id.toString():
query.setId(id.toString());
AbstractElasticsearchTemplate.getIndexQuery(T) uses elasticsearchConverter.convertId(id), and so do the reactive findById (SimpleReactiveElasticsearchRepository) and delete(entity).
Steps to reproduce
Use an entity whose @Id is a custom type, for example record ProductId(String value).
Register a Converter<ProductId, String> (returning value) and its reading counterpart in ElasticsearchCustomConversions.
With a ReactiveElasticsearchRepository<Product, ProductId>, call save(new Product(new ProductId("abc"), ...)), then findById(new ProductId("abc")).
Expected
The document is stored with _idabc and findById returns it, as with the imperative repository.
Actual
The document is stored with _idProductId[value=abc]. findById and deleteById look up abc and do not find it.
The fix would be to use converter.convertId(id) in the reactive getIndexQuery, which also covers save(Flux) and saveAll. I'd like to submit a PR with a unit test and imperative/reactive repository integration tests, if that's fine.
Activity
Use full name in @author tags.
Apply the id conversion when the reactive template saves an entity.