Skip to content

Instantly share code, notes, and snippets.

@yadu
Created August 1, 2012 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yadu/3230779 to your computer and use it in GitHub Desktop.
Save yadu/3230779 to your computer and use it in GitHub Desktop.
Default mapping for Elastic Search
{
"_default_" : {
"_id" : {
"path" : "item.@id",
"index": "not_analyzed",
"store" : "yes"
}
}
}
I put this default mapping to index.mapper.default_mapping_location: <path>/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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment