Change text mapping from text to integer

Good day!

Im creating new index, when I add this to "data views", it was tagged as TEXT type. I need it to be integer. do you have step by step guide for this case?

my temporary solution is this command -> emit (Integer.parseInt(doc['keyword'].value))

please ignore the "DATE", I already change the format.
Im using td-agent as log forwarder

  "indextrnxcount-000001" : {
    "mappings" : {
      "properties" : {
        "DATE" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "TransactionCount" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "tailed_path" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}

Thank you very much

Hi @Geeboy, you must try to create an index template here
image

Then select index template and create or edit your template
image

Here the documentation to do via dev tools in kibana.

thank you for the info. how can I insert my mappings in my sample template below?

{
  "index_templates" : [
    {
      "name" : "smpphourly-template",
      "index_template" : {
        "index_patterns" : [
          "smpphourly-*"
        ],
        "template" : {
          "settings" : {
            "index" : {
              "lifecycle" : {
                "name" : "180-days-default",
                "rollover_alias" : "index-alias"
              },
              "number_of_shards" : "1",
              "number_of_replicas" : "0"
            }
          },
          "mappings" : {
            "_source" : {
              "enabled" : true
            }
          }
        },
        "composed_of" : [ ]
      }
    }
  ]
}

Hi, here an example:

PUT _index_template/smpphourly-template
{
  "template": {
    "settings" : {
	  "index" : {
	    "lifecycle" : {
		  "name" : "180-days-default",
		  "rollover_alias" : "index-alias"
		},
		"number_of_shards" : "1",
        "number_of_replicas" : "0"
      }
    }
    "mappings": {
      "dynamic": true,
      "numeric_detection": false,
      "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": []
      },
      "_routing": {
        "required": false
      },
      "dynamic_templates": [],
      "properties": {
        "TransactionCount": {
          "type": "integer"
        }
      }
    }
  },
  "index_patterns": [
    "smpphourly-*"
  ]
}
1 Like

thank you very much @cperzrt10 . great help :slight_smile:

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.