Elasticsearch 创建mapping

一、创建 mapping

我们可以通过 curl 命令来创建也可以使用 postman 工具等

# 自定义mapping test.org
PUT test
{
    "mapping": {
        "properties": {
            "id": {
                "type": "keyword"
            },
            "name": {
                "type": "keyword"
            }
        }
    }
}

 

curl -XPUT  localhost:9200/twitter/_mapping/tweet -d 
'{
    "tweet" : {
        "properties" : {
            "message" : {"type" : "string", "store" : true }
        }
    }
}
'

 二、删除 mapping

curl -XDELETE localhost:9200/test/test
或者
curl -XDELETE localhost:9200/test/test/_mapping
或者
curl -XDELETE localhost:9200/test/_mapping/test

 三、修改 mapping 字段

 1)自定义一个新的mapping的索引,与需要修改的一致

 2)把旧索引的数据reindex到新索引上

POST _reindex
{
  "source": {
    "index": ""
  },
  "dest": {
    "index": ""
  }
}

 3)删除旧的索引

 4)创建修改后的索引

 5)重复步骤二把索引改回来

 四、查看mapping详情

# GET 请求
curl -XGET localhost:9200/test/_mapping
posted @ 2021-01-21 15:27  你的小可爱吖  阅读(599)  评论(0编辑  收藏  举报