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

**URL:** <https://discuss.elastic.co/t/is-there-a-way-to-get-value-of--id-or-assign-value-of--id-to-another-field-in-elastic-search/60879>\
**Category:** Elasticsearch\
**Created:** [September 19, 2016, 12:20pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-get-value-of--id-or-assign-value-of--id-to-another-field-in-elastic-search/60879 "2016-09-19T12:20:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elita\_Lobo](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Elita\_Lobo](https://discuss.elastic.co/u/Elita_Lobo)\
**Post date:** [September 19, 2016, 12:20pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-get-value-of--id-or-assign-value-of--id-to-another-field-in-elastic-search/60879/1 "2016-09-19T12:20:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)\
**Post date:** [September 19, 2016, 1:58pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-get-value-of--id-or-assign-value-of--id-to-another-field-in-elastic-search/60879/2 "2016-09-19T13:58:09Z")

</div>

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

Isabel

---

<div class="post-metadata">

**Author:** ![Elita\_Lobo](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Elita\_Lobo](https://discuss.elastic.co/u/Elita_Lobo)\
**Post date:** [September 19, 2016, 2:18pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-get-value-of--id-or-assign-value-of--id-to-another-field-in-elastic-search/60879/3 "2016-09-19T14:18:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)\
**Post date:** [September 22, 2016, 12:41pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-get-value-of--id-or-assign-value-of--id-to-another-field-in-elastic-search/60879/4 "2016-09-22T12:41:08Z")

</div>

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

Isabel

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:18pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-get-value-of--id-or-assign-value-of--id-to-another-field-in-elastic-search/60879/5 "2017-07-05T22:18:07Z")

</div>


