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
This is not possible at the moment. What would be the use case to have a customized name for this field name, which is a field internally by Spring Data Elasticsearch ?
i am working on a search only project which need to read a big index stores more than 10 years data. we already have a filed play similar document type role. it is really a overkill for me to re-index all old documents to add the new filed. either a customized filed name or a callback hook could create sub-classes both works for my case, but neither of them are available in current release.
So you have an index that contains documents that correspond to different entity classes in your application, and you have a field in your index that contains the full qualified name of the respective class? Do this classes have a common base class that you will use in Spring Data Elasticsearch as entity class when reading the data?
One thing to solve this would be to allow the configuration of the type hint field name as you suggest. A better way would be to have a lifecycle callback that is invoked after the data has been read from Elasticsearch and before it is mapped into an entity. In this callback you could add a _class field that contains the value of your field that has the class name.
There is an open issue to add that callback (#2009).
@sothawo, yes we have a base entity class. i am using mapstruct with customized converter function to do this right now. but i think it will be great to have the native feature in this library.
Activity
sothawo commentedon Dec 16, 2021
This is not possible at the moment. What would be the use case to have a customized name for this field name, which is a field internally by Spring Data Elasticsearch ?
jinwg commentedon Dec 16, 2021
i am working on a search only project which need to read a big index stores more than 10 years data. we already have a filed play similar document type role. it is really a overkill for me to re-index all old documents to add the new filed. either a customized filed name or a callback hook could create sub-classes both works for my case, but neither of them are available in current release.
[-]Use a customized typehit attribute name[/-][+]Use a customized typehint attribute name[/+]sothawo commentedon Dec 17, 2021
So you have an index that contains documents that correspond to different entity classes in your application, and you have a field in your index that contains the full qualified name of the respective class? Do this classes have a common base class that you will use in Spring Data Elasticsearch as entity class when reading the data?
One thing to solve this would be to allow the configuration of the type hint field name as you suggest. A better way would be to have a lifecycle callback that is invoked after the data has been read from Elasticsearch and before it is mapped into an entity. In this callback you could add a
_class
field that contains the value of your field that has the class name.There is an open issue to add that callback (#2009).
jinwg commentedon Dec 17, 2021
@sothawo, yes we have a base entity class. i am using mapstruct with customized converter function to do this right now. but i think it will be great to have the native feature in this library.
7 remaining items