elasticsearch create mapping

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/h_sn9999/article/details/102769660

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.

In short, Mapping Mapping is the key to determine the specific type of data and determine whether the data word

The following is a specific creation


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"

         }
      }
    
  }
}

 

 

 

Production systems need to pay attention to the following two configuration

"number_of_shards": 1, ## big data, you need more and more data node, you can put a balanced distribution of data to a different node, can be distributed query (parallel)
"number_of_replicas": 0 ### Set the number of copies, improve data security line, while improving query performance

**** number of fragments can not be changed after creation, you can copy

View fragmentation information:

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

kibanna View:

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

 

Guess you like

Origin blog.csdn.net/h_sn9999/article/details/102769660