当先锋百科网

首页 1 2 3 4 5 6 7

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