# How to create a mapping where \_id is from an array element?

**URL:** <https://discuss.elastic.co/t/how-to-create-a-mapping-where--id-is-from-an-array-element/2637>\
**Category:** Elasticsearch\
**Created:** [June 14, 2015, 5:04am UTC](https://discuss.elastic.co/t/how-to-create-a-mapping-where--id-is-from-an-array-element/2637 "2015-06-14T05:04:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlambert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rlambert/32/659_2.png) [@rlambert](https://discuss.elastic.co/u/rlambert)\
**Post date:** [June 14, 2015, 5:04am UTC](https://discuss.elastic.co/t/how-to-create-a-mapping-where--id-is-from-an-array-element/2637/1 "2015-06-14T05:04:23Z")

</div>

Fellow ElasticSearchers...

I have the a document type that includes a JSON block like this:

```
"identifiers": [
    {
        "name": "PolicyId",
        "value": "6bc3daab469b401f86e5aa0fd5982fe7" <--- I want this to be the document Id
    },
    {
        "name": "QuoteNumber",
        "value": "471657"
    },
    {
        "name": "TertiaryId",
        "value": "LBD000004206"
    }
],

```

How the heck do I create a mapping that will use the value of the "value" element in the array element where the name = 'PolicyId'?

Thanks,

== Ross ==

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [June 14, 2015, 5:46am UTC](https://discuss.elastic.co/t/how-to-create-a-mapping-where--id-is-from-an-array-element/2637/2 "2015-06-14T05:46:45Z")

</div>

if i understand you correctly, you want to use the value of the array's value to be the id of the indexed doc? you can do that during indexing right? just extract the id you want and then index it? or you can use path, [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-id-field.html#\_path](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-id-field.html#_path) but not that, this has been deprecated in 1.5

hth

---

<div class="post-metadata">

**Author:** ![rlambert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rlambert/32/659_2.png) [@rlambert](https://discuss.elastic.co/u/rlambert)\
**Post date:** [June 14, 2015, 6:46pm UTC](https://discuss.elastic.co/t/how-to-create-a-mapping-where--id-is-from-an-array-element/2637/3 "2015-06-14T18:46:26Z")

</div>

> if i understand you correctly, you want to use the value of the array's value to be the id of the indexed doc?

Nope, I am wanting the document ID (\_id) to be the value of the "value" field when the value of the name field is "PolicyId".

Thanks,

== Ross ==

---

<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 6, 2017, 12:07am UTC](https://discuss.elastic.co/t/how-to-create-a-mapping-where--id-is-from-an-array-element/2637/4 "2017-07-06T00:07:36Z")

</div>


