自定义mapping的api
PUT test_index { "mappings": { #mappings关键字 "doc": { #type "properties": { #字段名称和类型的定义 "name":{ #字段名 "type": "keyword" #字段类型 }, "message":{ "type": "text" }, "age":{ "type": "integer" } }}}}
- mapping中字段类型一旦设定后 禁止直接修改。因为lucene实现的倒排索引生成后不允许修改
- 除非重建索引映射,然后做reindex操作。
View Code
1,POST _reindex { "source": {"index":"旧索引"}, "dest": {"index":"备份索引"} } 2,删除旧索引 3,新索引建立mapping 4,POST _reindex { "source": {"index":"备份索引"}, "dest": {"index":"新索引"} }