Skip to content

Instantly share code, notes, and snippets.

@channainfo
Forked from kimchy/explicit data mapping
Created November 19, 2021 03:37
Show Gist options
  • Save channainfo/78f819797afeba6a152e0140a8ff8c7c to your computer and use it in GitHub Desktop.
Save channainfo/78f819797afeba6a152e0140a8ff8c7c to your computer and use it in GitHub Desktop.
curl -XPUT localhost:9200/test
curl -XPUT http://localhost:9200/test/data/_mapping -d '{
"data" : {
"dynamic_templates" : [
{
"string_template" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "multi_field",
"fields" : {
"{name}" : {"type": "string", "index" : "analyzed", "analyzer" : "default", "store" : "false", "include_in_all": "true"},
"{name}_untouched" : {"type": "string", "index" : "analyzed", "analyzer" : "simple", "store" : "false"}
}
}
}
}
]
}
}'
curl -XPUT http://localhost:9200/test -d '{
"mappings" : {
"_default_" : {
"dynamic_templates" : [
{
"string_template" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "multi_field",
"fields" : {
"{name}" : {"type": "string", "index" : "analyzed", "analyzer" : "default", "store" : "false", "include_in_all": "true"},
"{name}_untouched" : {"type": "string", "index" : "analyzed", "analyzer" : "simple", "store" : "false", "include_in_all": "true"}
}
}
}
}
]
}
}
}'
When I now add an object:
curl -XPUT http://localhost:9200/test/data/1 -d '{
"name" : "michael",
"company" : {
name: "foobar"
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment