Mapping 索引映射


Mapping | Elasticsearch Reference [7.6] | Elastic

Mapping 映射是定义文档及其包含的字段如何存储和索引的过程。例如,使用映射来定义:

字段映射构成:

一个映射定义包含以下:

Dynamic Mapping 动态映射

https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-mapping.html

在创建文档时,可以不指定字段类型,由 es 进行动态映射, Dynamic field mapping

新增映射

PUT /twitter/_mapping
{
  "properties": {
    "email": {
      "type": "keyword"
    }
  }
}
PUT /publications
{
    "mappings": {
        "properties": {
            "id": { "type": "text" },
            "title":  {	"type": "text" },
            "abstract": { "type": "text"},
            "author": {
                "properties": {
                    "id": { "type": "text" },
                    "name": { "type": "text" }
                }
            }
        }
    }
}