Created
August 1, 2012 21:08
-
-
Save yadu/3230779 to your computer and use it in GitHub Desktop.
Default mapping for Elastic Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_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