Default mapping does not get triggered on first request


(Yadu) #1

Default mapping does not get triggered on very first request but works well
on second request onwards.

Please find complete set of operation on this gist:

For quick reference:

{
"default" : {
"_id" : {
"path" : "item.@id",
"index": "not_analyzed",
"store" : "yes"
}
}
}

I put this default mapping to index.mapper.default_mapping_location: /default-mapping.json. Then created test index

curl -XPOST 'http://localhost:9200/test' -d '{}'

Response:
{
"ok": true,
"acknowledged": true
}

Tried to add content to article type

curl -XPOST 'http://localhost:9200/test/article' -d '
{
"item": {
"@id": "26883238",
"@name": "yankees vs redsox"
}
}
'

Response:
{
"ok": true,
"_index": "test",
"_type": "article",
"_id": "DWXgRADCSNqk36faFx3ICg",
"_version": 1
}

Posted same item again and I got response as expected with correct Id (extracted from content)

{
"ok": true,
"_index": "test",
"_type": "article",
"_id": "26883238",
"_version": 1
}

So my question is, why the id was not picked up on very first attempt?

This resulted in two copies of the same item, one with auto generated id and other with id extracted from content.

Appreciate your help!

Thanks
Yadu


(system) #2