document mapping

只能创建index时手动建立mapping,或者新增field mapping,但是不能修改 field mapping

查看mapping

GET /index/_mapping/type

"index"参数-的分词情况

值:2017-08-15

  • analyzed :会拆分成 2017,01,15等进行索引

  • not_analyzed:不分词,2017-08-15作为整体索引

  • no 不分词不索引(不索引也就是不参与搜索)

analyzer参数-分词器

核心的数据类型 type

string: text , keyword
byte,short,integer,long
float,double
boolean
date

示例

手动创建mapping

修改mapping 会报错

为什么不能修改一个字段的type?原因是一个字段的类型修改以后,那么该字段的所有数据都需要重新索引。Elasticsearch底层使用的是lucene库,字段类型修改以后索引和搜索要涉及分词方式等操作,不允许修改类型在我看来是符合lucene机制的。

报错:

新增field: ok

资料:

Elasticsearch索引mapping的写入、查看与修改

Last updated

Was this helpful?