elasticsearch 创建 mapping

Mapping is the process of defining how a document, and the fields it contains, are stored and indexed. For instance, use mappings to define:

  • which string fields should be treated as full text fields.
  • which fields contain numbers, dates, or geolocations.
  • the format of date values.
  • custom rules to control the mapping for dynamically added fields.

简而言之,Mapping就是数据的映射关键,决定具体的数据类型及判断是否被分词

下面是具体的创建过程


PUT test_index2
{
  "settings":{
           "number_of_shards":1, 
           "number_of_replicas":0     
            },
  "mappings": {
      "dynamic": false,
      "properties": {
        "title": {
          "type": "text"
        },
        "name": {
          "type": "keyword"
        },
        "size": {
          "type": "integer"
        },
          "price": {
          "type": "integer"
        },
        "area": {
          "type": "integer"
        },
        "createTime": {
          "type": "date",
          "format": "strict_date_optional_time||epoch_millis"
        },
        "lastUpdateTime": {
          "type": "date",
          "format": "strict_date_optional_time||epoch_millis"
        },
        "layoutDesc" : {
          "type": "text"

         }
      }
    
  }
}

 

 

 

生产系统需要注意下面两个配置

"number_of_shards":1,   ##数据大,就需要多些数据节点,可以把数据均衡分布到不同的节点,可以分布式的查询(并行)
"number_of_replicas":0  ###设置副本数量,提高数据安全行,同时提升查询性能

****分片的数量创建后不能改变,副本可以

查看分片信息:

http://127.0.0.1:9200/test_index2/_settings?pretty

kibanna查看:

GET test_index2/_settings?pretty
GET test_index2/_mapping?pretty

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值