# How to show field "name" value by id in results - ES6.3

**URL:** <https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318>\
**Category:** Elasticsearch\
**Created:** [June 25, 2018, 9:28pm UTC](https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318 "2018-06-25T21:28:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erick\_Costa](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@Erick\_Costa](https://discuss.elastic.co/u/Erick_Costa)\
**Post date:** [June 25, 2018, 9:28pm UTC](https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318/1 "2018-06-25T21:28:59Z")

</div>

I'm trying to do in one query, the 10 most rented, display a text field (name) of another document that are in the same index but are of different types.

Example:  
{  
"id": 1,  
"id\_book": 1  
"type": "books"  
"name": "My book one"  
}

{  
"id": "7QTwKGQBPPR4nU-GIJQH"  
"type": "rented"  
"id\_book": 1  
}

How do I change the id\_book by name in my result?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 26, 2018, 6:53am UTC](https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318/2 "2018-06-26T06:53:18Z")

</div>

You can't do join at search time easily in elasticsearch and I'd not recommend doing so.

Better to do join at index time and index things like:

```auto
{
  "id": "7QTwKGQBPPR4nU-GIJQH"
  "type": "rented"
  "book": {
    "id": 1,
    "id_book": 1
    "type": "books"
    "name": "My book one"
  }
}

```

---

<div class="post-metadata">

**Author:** ![Erick\_Costa](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@Erick\_Costa](https://discuss.elastic.co/u/Erick_Costa)\
**Post date:** [June 26, 2018, 1:13pm UTC](https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318/3 "2018-06-26T13:13:49Z")

</div>

Thanks David,

But if I need to change the name of the book, the elasticsearch will do this for all records quickly?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 26, 2018, 1:43pm UTC](https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318/4 "2018-06-26T13:43:32Z")

</div>

So I guess it was not a real use case but an example as normally a book is pretty much stable once it got printed.

Anyway, it depends. How many instances are going to update? 10? 1000? 10000? 10000000? Depending on that it can time lot of time or nothing.

Would be better to talk about the real use case. But for a use case I have, it takes me around 1 or 2 minutes to index locally 1 million documents (again for my use case). So I'm totally fine having to reindex 1m documents if a value is changing like the book title in your case.

Otherwise, you can look at parent/child feature **if you really need it**. See the **bold** text? My advice is to keep things as simple as possible. Parent/child feature comes with some drawbacks so I'd use that only on last resort IMHO.

---

<div class="post-metadata">

**Author:** ![Erick\_Costa](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@Erick\_Costa](https://discuss.elastic.co/u/Erick_Costa)\
**Post date:** [June 26, 2018, 2:21pm UTC](https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318/5 "2018-06-26T14:21:48Z")

</div>

Hi,

I have a tracking system that sends data every 180 seconds. Today we have 4000 vehicles.

"\_source": {  
"plate": "TTT0003",  
"userid": 1,  
"type": "historical",  
"post\_date": "2018-06-26T11: 15: 16-03: 00",  
"ignition": false,  
"created": "2018-06-26T11: 15: 19-03: 00",  
"vehicle\_id": 6599,  
"crawler\_id": 14571,  
"vehicle": "TTT0003",  
"speed": "000,000",  
"ignicao\_tempo": 120,  
"location": {  
"lat": "-22.816104",  
"lon": "-043.383314"  
}  
},

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 26, 2018, 2:38pm UTC](https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318/6 "2018-06-26T14:38:52Z")

</div>

So what is supposed to change in this model?

---

<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 24, 2018, 2:38pm UTC](https://discuss.elastic.co/t/how-to-show-field-name-value-by-id-in-results-es6-3/137318/7 "2018-07-24T14:38:53Z")

</div>

Closed on July 24, 2018, 2:38pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
