Created
December 7, 2012 16:37
-
-
Save tudorleu/4234508 to your computer and use it in GitHub Desktop.
Elasticsearch - changing dynamic mapping to strict
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
# 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