spring-data-elasticsearch
spring-data-elasticsearch copied to clipboard
Fix `convertId` and `stringIdRepresentation` usage in template and repository classes.
These two methods are used inconsistently, it seems that not all requests do a proper conversion of an ID
but only a string representation - for example when indexing an entity with a custom id class, the toString()
representation is used for the document id in Elasticsearch.
Good time of the day!
I would like to work on solving this problem, can you please provide some guide lines about where better to start from?
Thank you in advance !
Hello, great that you want to help out.
This issue is some internal refactoring thing I came across recently. It's about the conversion of the id of an entity (which might be any class) to a String when issuing a call to Elasticsearch.
There are currently two functions used for this:
-
org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter#convertId(Object)
-
org.springframework.data.elasticsearch.core.ElasticsearchOperations#stringIdRepresentation(Object)
The first one is the one that should be used, as this uses the conversion service in he ElasticsearchConverter
. If you have a custom id class I
and register a converter from String> to
I~ and back, these converters should be used.
So basically what would be needed for this ticket (imperative, non reactive code):
- add a
String convertId(Object o)
method to theElasticsearchOperations
interface, this could as a default implementation call theconvertId()
method of it's converter. - deprecated the
stringIdRepresentation
method with a reference to the new method.
Is this enough information to get you started?
Thank you for such good guide lines.
For now I think that is enough. I will start and probably after I will have something to ask.
Thank you!
Hi @Nik9695, any progress on this?