创建索引的分步指南?
Step-by-step guide for creating index?
我正在寻找在 elasticsearch 中创建索引的指南,但它并不像以下位置提供的指南那么简单:
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
我想做的事情似乎很简单,但我似乎无法让它发挥作用。现在,我希望我的索引是每日索引(与默认的 logstash 索引相同)但有一些变化。这些更改包括名称更改和具有特定类型的字段的特定映射。现在我知道我必须在 logstasg 配置的 output-elasticsearch 部分指定:
index => "name-%{+YYYY.MM.dd}"
我找到的唯一信息是可以基于模板创建索引,我尝试创建模板但仍然没有任何反应。
创建模板我使用了以下内容:
PUT _template/ids
{
"template": "ids-*",
"order": 0,
"settings": {
"index": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"log": {
"_all": {
"enabled": true,
"omit_norms": true
},
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"type": "string",
"index": "not_analyzed"
},
"field1": {
"type": "string",
"index": "not_analyzed"
},
"field2": {
"type": "string",
"index": "not_analyzed"
},
对于 "some changes" 的每日指数,使用模板非常好。
要检查集群中已经设置了哪些模板,请使用:
GET {es_url}/_template
要为集群设置新模板,请使用:
PUT {es_url}/_template/ids
{
"template": "ids-*",
"order": 0,
"settings": {
"index": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"log": {
"_all": {
"enabled": true,
"omit_norms": true
},
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"type": "string",
"index": "not_analyzed"
},
"field1": {
"type": "string",
"index": "not_analyzed"
},
"field2": {
"type": "string",
"index": "not_analyzed"
}
}
}
}}}
要删除现有模板,请使用:
DELETE {es_url}/_template/{template_name}
如果您将 "ids" 模板设置为集群 - 将插入集群的任何文档,使用匹配 "ids-*" 的名称进行索引(又名 "ids-123","ids-sheker", "ids-2016.05.02") 会得到插入的ids模板的映射。
我正在寻找在 elasticsearch 中创建索引的指南,但它并不像以下位置提供的指南那么简单:
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
我想做的事情似乎很简单,但我似乎无法让它发挥作用。现在,我希望我的索引是每日索引(与默认的 logstash 索引相同)但有一些变化。这些更改包括名称更改和具有特定类型的字段的特定映射。现在我知道我必须在 logstasg 配置的 output-elasticsearch 部分指定:
index => "name-%{+YYYY.MM.dd}"
我找到的唯一信息是可以基于模板创建索引,我尝试创建模板但仍然没有任何反应。
创建模板我使用了以下内容:
PUT _template/ids
{
"template": "ids-*",
"order": 0,
"settings": {
"index": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"log": {
"_all": {
"enabled": true,
"omit_norms": true
},
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"type": "string",
"index": "not_analyzed"
},
"field1": {
"type": "string",
"index": "not_analyzed"
},
"field2": {
"type": "string",
"index": "not_analyzed"
},
对于 "some changes" 的每日指数,使用模板非常好。
要检查集群中已经设置了哪些模板,请使用:
GET {es_url}/_template
要为集群设置新模板,请使用:
PUT {es_url}/_template/ids
{
"template": "ids-*",
"order": 0,
"settings": {
"index": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"log": {
"_all": {
"enabled": true,
"omit_norms": true
},
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"type": "string",
"index": "not_analyzed"
},
"field1": {
"type": "string",
"index": "not_analyzed"
},
"field2": {
"type": "string",
"index": "not_analyzed"
}
}
}
}}}
要删除现有模板,请使用:
DELETE {es_url}/_template/{template_name}
如果您将 "ids" 模板设置为集群 - 将插入集群的任何文档,使用匹配 "ids-*" 的名称进行索引(又名 "ids-123","ids-sheker", "ids-2016.05.02") 会得到插入的ids模板的映射。