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


(Ross William Lambert) #1

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 ==


(Jason Wee) #2

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 but not that, this has been deprecated in 1.5

hth


(Ross William Lambert) #3

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 ==


(system) #4