Is there a way to get value of _id or assign value of _id to another field in elastic search?


(Elita Lobo) #1

Is there a way to get value of _id or assign value of _id to another field in elastic search?


(Isabel Drost-Fromm) #2

Can you elaborate a bit please - I don't get your question.

Isabel


(Elita Lobo) #3

I am using spring - data elastic search.

I am storing a document which looks like this

public class Image {

@Id
private String id;
private String url;
private String url_thumbnail;
private String description;
@Field( type = FieldType.Nested)
private List<Tag> tags;
private String source;

I want the id field to take the value of _id ( generated by elastic search when id=null) . Is there any way I can get the value of _id after an object is saved into the repository? If I can get the value , I can set id to that value.
If there is a way to map id to _id such that everytime an object is created using id=null, id will take the value of _id generated by elastic search api, then that would be helpful too.


(Isabel Drost-Fromm) #4

My suggestion would be to ask the spring-data community directly. I'm sure they are better at helping you out...

Isabel


(system) #5