# Add unique value for each fields

**URL:** <https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695>\
**Category:** Elasticsearch\
**Created:** [June 10, 2023, 4:43pm UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695 "2023-06-10T16:43:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sevbans](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sevbans/32/112112_2.png) [@sevbans](https://discuss.elastic.co/u/sevbans)\
**Post date:** [June 10, 2023, 4:43pm UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695/1 "2023-06-10T16:43:07Z")

</div>

I have a index something like this:

 ![Screenshot 2023-06-10 191513](https://us1.discourse-cdn.com/elastic/original/3X/e/6/e698404d44244af60d5852e1e82ab6c3634f5347.png)

All countries' names, along with their populations, exist in my index. Since Kibana does not allow us to use the countries' normal names, I have to add unique country codes such as FR, KR, TR....

Could it possible? How to cope with it?

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [June 11, 2023, 2:39am UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695/2 "2023-06-11T02:39:18Z")

</div>

> [@sevbans](#):
>
> Since Kibana does not allow us to use the countries' normal names, I have to add unique country codes such as FR, KR, TR....

Where can you not use the normal (I assume full) name of countries in Kibana?

---

<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 11, 2023, 6:59am UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695/3 "2023-06-11T06:59:13Z")

</div>

I guess it's for maps when you want to highlight the country and you don't have a geo point.

You can provide a synonym list which converts each country name as its ISO code (I d apply this analyzer to a new sub field like country.code) or use an ingest pipeline to create a new field like country\_code.  
.

---

<div class="post-metadata">

**Author:** ![sevbans](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sevbans/32/112112_2.png) [@sevbans](https://discuss.elastic.co/u/sevbans)\
**Post date:** [June 11, 2023, 10:55am UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695/4 "2023-06-11T10:55:50Z")

</div>

On kibana, when i try to create a choropleth map, if i choose the world countries option;

 ![Screenshot 2023-06-11 135249](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a514961b9032a9fb2faa895132d447dcd6dc1de0.jpeg)

it displays this message.

---

<div class="post-metadata">

**Author:** ![sevbans](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sevbans/32/112112_2.png) [@sevbans](https://discuss.elastic.co/u/sevbans)\
**Post date:** [June 11, 2023, 10:59am UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695/5 "2023-06-11T10:59:23Z")

</div>

I shouldn't convert country fields to their ISO code. I must add extra fields for this. I guess i should use enrichment data but I don't know how can i provide this.

Could you explain gradually?

---

<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 11, 2023, 1:17pm UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695/6 "2023-06-11T13:17:08Z")

</div>

Some doc about synonyms here: [Synonym token filter | Elasticsearch Guide [8.8] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html)

Some doc about ingest pipelines here and the enrich processor here: [Enrich your data | Elasticsearch Guide [8.8] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-enriching-data.html)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [June 11, 2023, 9:26pm UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695/7 "2023-06-11T21:26:30Z")

</div>

Another option is a [runtime lookup field](https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime-retrieving-fields.html#lookup-runtime-fields) might be a good way to test see if it works for you, you might need to add it to the mapping not data view for it to work in a map ...you need to check that, I have not tried that yet.

Probably the best approach is the enrich processor that @dadoonet suggested.

---

<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 9, 2023, 9:27pm UTC](https://discuss.elastic.co/t/add-unique-value-for-each-fields/335695/8 "2023-07-09T21:27:03Z")

</div>

Closed on July 9, 2023, 9:27pm UTC

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