世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
1.
问 :mapping的作用是什么?
答 :mapping定义了一个文档及它所包含的域如何存储和索引。
2.
问 :mapping定义了那些内容?
答 :
1. metadata fields : _index _id _source
2. fields : propreties and data type
3.
问 :什么导致了mapping激增?
答 :dynamic mapping
问 :防止mapping激增的参数有哪些?
答 :
1. index.mapping.total_fields.limit : 每个索引包含field的最大数量,默认1000
2. index.mapping.depth.limit : 每个field的最大深度,即内部对象的最大层数,默认20
3. index.mapping.nested_fields.limit : 每个索引内嵌mapping的最大数量,默认50
4. index.mapping.nested_objects.limit : 每个文档包含的最大的嵌套对象的数量,默认10000
5. index.mapping.field_name_length.limit : 域名的最大长度,默认Long.MAX_VALUE
4.
问 :如何在创建索引时配置mapping?
答 :
PUT /mapping_test_1
{
"mappings": {
"properties": {
"age" : {"type" : "integer"},
"email" : {"type" : "keyword"},
"name" : {"type" : "text"}
}
}
}
问 :如何为已有索引增加mapping?
答 :
PUT /mapping_test_1/_mapping
{
"properties" : {
"address" : {"type" : "text"}
}
}
问 :如何查看当前索引的所有mapping?
答 :
GET /mapping_test_1/_mapping
# 结果
{
"mapping_test_1" : {
"mappings" : {
"properties" : {
"address" : {
"type" : "text"
},
"age" : {
"type" : "integer"
},
"email" : {
"type" : "keyword"
},
"name" : {
"type" : "text"
}
}
}
}
}
问 :如何查看当前索引某个field的mapping?
答 :
GET /mapping_test_1/_mapping/field/address
# 结果
{
"mapping_test_1" : {
"mappings" : {
"address" : {
"full_name" : "address",
"mapping" : {
"address" : {
"type" : "text"
}
}
}
}
}
}