如何检测elasticsearch是否启用动态字段
How to detect whether elasticsearch has enabled dynamic field
我不知道我的索引是否有 enabled/disabled 动态字段。当我使用 get index mapping 命令时,它只响应这些信息:
GET /my_index1/_mapping
{
"my_index1": {
"mappings": {
"properties": {
"goodsName": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"auditTime": {
"type": "long"
},
"createUserId": {
"type": "long"
}
}
}
}
}
如果您没有明确将 dynamic
设置为 false
或 strict
,则默认为 true
。如果您明确设置它,您将在映射中看到:
{
"mappings": {
"dynamic": false,
"properties": {
"name": {
"type": "text"
}
}
}
}
并且当您索引以下文档时:
{"name":"products", "clickCount":1, "bookingCount":2, "isPromoted":1}
只有字段 name
会被索引,其余的不会。如果您再次调用 _mapping
端点,它将为您提供上面的确切映射。
我不知道我的索引是否有 enabled/disabled 动态字段。当我使用 get index mapping 命令时,它只响应这些信息:
GET /my_index1/_mapping
{
"my_index1": {
"mappings": {
"properties": {
"goodsName": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"auditTime": {
"type": "long"
},
"createUserId": {
"type": "long"
}
}
}
}
}
如果您没有明确将 dynamic
设置为 false
或 strict
,则默认为 true
。如果您明确设置它,您将在映射中看到:
{
"mappings": {
"dynamic": false,
"properties": {
"name": {
"type": "text"
}
}
}
}
并且当您索引以下文档时:
{"name":"products", "clickCount":1, "bookingCount":2, "isPromoted":1}
只有字段 name
会被索引,其余的不会。如果您再次调用 _mapping
端点,它将为您提供上面的确切映射。