elasticsearch7 创建映射

1.创建索引库

curl -XPUT 'localhost:9200/users'

2.创建类型及映射

curl -H 'Content-Type:application/json' -XPOST 'localhost:9200/users/user/?pretty' -d '{"mappings":{"properties":{"name":{"type":"string"}}}}'

 

提示:

{
  "_index" : "users",
  "_type" : "user",
  "_id" : "pfEOgXABz0KE1bvg9OEf",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}
 

添加一个phone字段

curl -H 'Content-Type:application/json' -XPOST 'localhost:9200/users/user/?pretty' -d '{"mappings":{"properties":{"phone":{"type":"string"}}}}'

 

3.查看映射

curl -XGET 'localhost:9200/users/_mapping?pretty'

 

你可能感兴趣的:(elasticsearch)