Skip to content

Instantly share code, notes, and snippets.

@stefnestor
Created December 22, 2022 16:42
Show Gist options
  • Save stefnestor/3e428f621cbcf43e7b4ada2b3e855f82 to your computer and use it in GitHub Desktop.
Save stefnestor/3e428f621cbcf43e7b4ada2b3e855f82 to your computer and use it in GitHub Desktop.
Override Index Field's Mapping Data Type
# Runtime: https://www.elastic.co/guide/en/elasticsearch/reference/8.5/runtime-mapping-fields.html
DELETE test_index
PUT test_index
{ "mappings": { "properties": { "myKey": { "type": "text" }}}}
POST test_index/_doc
{ "myKey": "myValue" }
GET test_index/_mapping
# {
# "test_index": {
# "mappings": {
# "properties": {
# "myKey": {
# "type": "text"
# }
# }
# }
# }
# }
GET test_index/_field_caps?fields=myKey
# {
# "indices": [
# "test_index"
# ],
# "fields": {
# "myKey": {
# "keyword": {
# "type": "keyword",
# "metadata_field": false,
# "searchable": true,
# "aggregatable": true
# }
# }
# }
# }
PUT test_index/_mapping
{ "runtime": { "myKey": { "type": "keyword" }}}
GET test_index/_mapping
# {
# "test_index": {
# "mappings": {
# "runtime": {
# "myKey": {
# "type": "keyword"
# }
# },
# "properties": {
# "myKey": {
# "type": "text"
# }
# }
# }
# }
# }
GET test_index/_field_caps?fields=myKey
# {
# "indices": [
# "test_index"
# ],
# "fields": {
# "myKey": {
# "keyword": {
# "type": "keyword",
# "metadata_field": false,
# "searchable": true,
# "aggregatable": true
# }
# }
# }
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment