Create es index - formatted and unformatted

Create es index - formatted and unformatted

Learned: https://www.imooc.com/video/15768

There is a distinction between structured and unstructured indexes;

1, first create the index, then POST to modify the mapping

First create an index, use the create index interface in the head plugin to create it;

然后POST http://localhost:9200/book/novel/_mappings

{
  "novel": {
    "properties": {
      "title": {
        "type": "text"
      }
    }
  }
}

 

2. Direct PUT index with mapping

PUT http://localhost:9200/people

{
    "settings":{
        "number_of_shards":3,
        "number_of_replicas":1
    },
    "mappings":{
        "man":{
            "properties":{
                "name":{
                    "type":"text"
                },
                "country":{
                    "type":"keyword"
                },
                "date":{
                    "type":"date",
                    "format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
                }
            }
        },
        "woman":{}
    }
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325122197&siteId=291194637