Skip to content

Instantly share code, notes, and snippets.

@teebu
Created August 12, 2020 21:49
Show Gist options
  • Save teebu/3e03b80c7f0a051d9c42f7088401fb1c to your computer and use it in GitHub Desktop.
Save teebu/3e03b80c7f0a051d9c42f7088401fb1c to your computer and use it in GitHub Desktop.
sample dynamic mapping
PUT mapping_test
{
"settings": {
"index": {
"number_of_shards": "1",
"refresh_interval": "1s"
}
},
"mappings": {
"numeric_detection": false, // treat numbers in strings as numbers
"date_detection": true,
"dynamic_date_formats": [
"strict_date_optional_time",
"yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
],
"_source": {
"enabled": true,
"includes": [],
"excludes": []
},
"_meta": {},
"_routing": {
"required": false
},
"dynamic_templates": [
{
"message_field": {
"path_match": "*.message",
"mapping": {
"norms": false,
"type": "text"
},
"match_mapping_type": "string"
}
},
{
"string_fields": {
"mapping": {
"type": "keyword",
"ignore_above": 256
},
"match_mapping_type": "string",
"match": "*"
}
}
],
"dynamic": false,
"properties": {
"name": { "type": "keyword" },
"event_type": { "type": "keyword" },
"attr": {
"dynamic": true,
"properties": {}
}
}
}
}
DELETE mapping_test
GET mapping_test/_mapping
GET mapping_test/_doc/1
PUT mapping_test/_doc/1
{
"name": "joe",
"non_field": "some text",
"date": "2020-07-10T06:42:32.697Z",
"attr": {
"dynamic_field": "yes",
"message": "should be text analyzed",
"number": 123,
"decimal": 123.33,
"dyn_date": "2020-07-10T06:42:32.697Z",
"obj": {
"name": "joey",
"message": "another text analyzed"
}
},
"non_dyn_obj": {
"one": 1,
"two": 2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment