TomonoriSoejima / Tejun

notes related to working cases
5 stars 3 forks source link

template test #87

Open TomonoriSoejima opened 1 year ago

TomonoriSoejima commented 1 year ago
# making legacy template with type text 
PUT /_template/template_1
{
  "index_patterns" : ["te*"],
  "order" : 0,
  "settings" : {
    "number_of_shards" : 1
  },
      "mappings": {
      "_source": {
        "enabled": true
      },
      "properties": {
        "ip_addr": {
          "type": "text"
        }
      }
    }
}

# making legacy template with type ip 
PUT /_template/ecs
{
  "index_patterns" : ["test*"],
  "order" : 20,
  "settings" : {
    "number_of_shards" : 1
  },
      "mappings": {
      "_source": {
        "enabled": true
      },
      "properties": {
        "ip_addr": {
          "type": "ip"
        }
      }
    }
}

# making index template 
PUT _index_template/template_1
{
  "index_patterns": [
    "te*"
  ],
  "template": {
    "settings": {
      "number_of_shards": 1
    },
    "mappings": {
      "_source": {
        "enabled": true
      },
      "properties": {
        "ip_addr": {
          "type": "text"
        }
      }
    },
    "aliases": {
      "mydata": {}
    }
  },
  "priority": 500,
  "composed_of": [],
  "version": 3,
  "_meta": {
    "description": "my custom"
  }
}

DELETE test

PUT test/_doc/1
{
  "ip_addr": "192.168.1.1"
}

# you will see type text
GET test/_mapping

# then delete index template 

DELETE  _index_template/template_1

# recreate test index
DELETE test

PUT test/_doc/1
{
  "ip_addr": "192.168.1.1"
}

# you will see type ip
GET test/_mapping