es 查看mapping

时间:2025-02-11 07:17:58

mapping,就是index的type的元数据,每个type都有自己一个mapping,决定了数据类型,建立倒排索引的行为,还有进行搜素的行为。

mapping核心的数据类型
string
byte,short,integer,long
float,double
boolean
date

查看mapping
GET /index/_mapping/type

定义string类型数据如何建立索引以及分词
1. analyzed     可以使用分词器
2. no analyzed  不使用分词器
3. no            不使用分词词,也不能检索

2. 修改mapping
只能创建index时手动建立mapping,或者新增field mapping,但是不能update field mapping
PUT /website
{
    "mapping":{
        "article":{
            "properties":{
                "content":{
                    "type": "string",
                    "analyzer":"english"
                },
                "post_date":{
                    "type":"date
                },
                "title":{
                    "type":"string"
                }
                "author_id":{
                    "type":"long"
                }
            }
        }
    }
}