【发布时间】:2018-09-12 04:17:22
【问题描述】:
我想要一个具有一些预定义字段(包括对象类型字段)的弹性搜索架构。我希望该对象类型字段中的所有字段默认为字符串。
我在创建索引时有以下映射和动态模板。
PUT myindex
{
"mappings": {
"doc": {
"dynamic_templates": [
{
"default_string": {
"path_match": "myObj.*",
"match_mapping_type": "*",
"mapping": {
"type": "text"
}
}
}],
"properties": {
"dummy_field_name": { "type": "text" },
"timestamp": {
"type": "date",
"format": "epoch_second"
},
"myObj": {
"type": "object"
}
}
}
}
}
但是当我在对象内提交一个带有数值的字段时,它并没有将该字段映射到字符串。
curl -XPOST "http://elastic-url:8080/myindex/test" -d
'{"dummy_field_name": "dymmy_value", "myObj":{ "filed_1": 123 ,
"field_2": "some value"}, "timestamp": 1522196333}'
“filed_1”被标识为数字字段。但我希望它存储为字符串类型。
【问题讨论】:
标签: elasticsearch kibana elasticsearch-5