# Return a dynamic field depending on value?

**URL:** <https://discuss.elastic.co/t/return-a-dynamic-field-depending-on-value/296897>\
**Category:** Kibana\
**Created:** [February 10, 2022, 9:00pm UTC](https://discuss.elastic.co/t/return-a-dynamic-field-depending-on-value/296897 "2022-02-10T21:00:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjswe](https://avatars.discourse-cdn.com/v4/letter/t/8e7dd6/32.png) [@tjswe](https://discuss.elastic.co/u/tjswe)\
**Post date:** [February 10, 2022, 9:00pm UTC](https://discuss.elastic.co/t/return-a-dynamic-field-depending-on-value/296897/1 "2022-02-10T21:00:55Z")

</div>

Hi!

I just need some guidance in the right direction...

I have an index with a field containing a value from lets say 1 to 10.

Is there a way in the presentation end in Kibana adding a new dynamic field with a word that translates to that number. So giving either Elasticsearch or Kibana a dictionary

For example

1 = Apple  
2 = Orange  
3 = Banana  
and so on

So a search would give something like "fruit\_num:2 fruit\_name:Orange", with fruit\_name being dynamic.

Is this runtime fields or i something else directly in Kibana? If anyone has an example similar to this?

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [February 12, 2022, 4:07pm UTC](https://discuss.elastic.co/t/return-a-dynamic-field-depending-on-value/296897/2 "2022-02-12T16:07:31Z")

</div>

Maybe there are several ways.

You may use format of field in index pattern. This only changes how to display the field. You have to query by original terms.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/e/ae87abc37c409c407d1e43f4b0aaca2cd411c155.png)

Of cource you may use [runtime mappings](https://www.elastic.co/guide/en/elasticsearch/reference/8.0/runtime-mapping-fields.html) to the index in Elasticsearch.

Or you may [enrich](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-enriching-data.html) data while indexing.

---

<div class="post-metadata">

**Author:** ![tjswe](https://avatars.discourse-cdn.com/v4/letter/t/8e7dd6/32.png) [@tjswe](https://discuss.elastic.co/u/tjswe)\
**Post date:** [February 12, 2022, 5:00pm UTC](https://discuss.elastic.co/t/return-a-dynamic-field-depending-on-value/296897/3 "2022-02-12T17:00:34Z")

</div>

Thanks!

Looks promising and what i was looking for!

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [February 12, 2022, 10:57pm UTC](https://discuss.elastic.co/t/return-a-dynamic-field-depending-on-value/296897/4 "2022-02-12T22:57:24Z")

</div>

If you satisfied with my post, please check as solution. Thanks!

---

<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:** [March 12, 2022, 10:57pm UTC](https://discuss.elastic.co/t/return-a-dynamic-field-depending-on-value/296897/5 "2022-03-12T22:57:29Z")

</div>

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