你可以用
index templates
这将在索引创建时自动应用。这个
模板可以包括设置和映射。
对于您的数据,您可以创建这样一个索引模板,它将匹配任何匹配的索引
foo-*
和
bar-*
PUT/ _template/foobar
{
"index_patterns": [
"foo-*",
"bar-*"
],
"mappings": {
"properties": {
"id": {
"type": "keyword"
},
"src_location": {
"type": "geo_point"
},
"dst_location": {
"type": "geo_point"
}
}
}
}
POST/ foo-1/_doc/1
{
"id": 158,
"src_location": "1.486912, 2.493157",
"dst_location": "11.489026, -22.501309"
}
检索索引的映射时。你会得到这个的
GET /foo-1/_mapping
{
"foo-1": {
"mappings": {
"properties": {
"dst_location": {
"type": "geo_point"
},
"id": {
"type": "keyword"
},
"src_location": {
"type": "geo_point"
}
}
}
}
}