elasticsearch 版本为6.1.4
索引的文档包含的字段种类较多,并且后续会补充新的类型,但用于查询的字段只有固定的6,7个,如何设置新增字段不索引?
这里我所表达的“新增字段”是指在创建索引时mapping中没有指定的字段,后续插入时自己判定类型的字段。
elasticsearch 版本为6.1.4
索引的文档包含的字段种类较多,并且后续会补充新的类型,但用于查询的字段只有固定的6,7个,如何设置新增字段不索引?
这里我所表达的“新增字段”是指在创建索引时mapping中没有指定的字段,后续插入时自己判定类型的字段。
1 回答2.7k 阅读
1 回答1.2k 阅读
已解决,创建索引时可将dynamic设为false。
dynamic相关描述:
By default, when a previously unseen field is found in a document, Elasticsearch will add the new field to the type mapping. This behaviour can be disabled, both at the document and at the
object
level, by setting thedynamic
parameter tofalse
(to ignore new fields) or tostrict
(to throw an exception if an unknown field is encountered).官方文档:
https://www.elastic.co/guide/...