Skip to content

Instantly share code, notes, and snippets.

@tudorleu
Created December 7, 2012 16:37
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 tudorleu/4234508 to your computer and use it in GitHub Desktop.
Save tudorleu/4234508 to your computer and use it in GitHub Desktop.
Elasticsearch - changing dynamic mapping to strict
# Create an index
curl -XPUT 'http://localhost:9200/testindex/'
# Create a first mapping
curl -XPUT 'http://localhost:9200/testindex/test1/_mapping' -d '
{
"test1" : {
"properties" : {
"name" : {"type" : "string"}
}
}
}
'
# Try to change the dynamic mapping to strict.
curl -XPUT 'http://localhost:9200/testindex/test1/_mapping' -d '
{
"test1" : {
"dynamic" : "strict"
}
}
'
# Check the mapping, the dynamic mapping setting has not been applied.
curl -XGET 'http://localhost:9200/testindex/_mapping?pretty=true'
# Add a document with a field not present in the mapping.
curl -XPUT 'http://localhost:9200/testindex/test1/1' -d '
{
"name" : "Foo",
"attribute" : "Bar"
}'
# The new field has been added to the mapping
curl -XGET 'http://localhost:920/testindex/test1/_mapping?pretty=true'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment