需求:根据时间提取es数据
解决:为es的记录添加时间戳
1、方法
配置时间戳 pipeline
PUT _ingest/pipeline/my_timestamp_pipeline
{
"description": "Adds a field to a document with the time of ingestion",
"processors": [
{
"set": {
"field": "@timestamp",
"value": "{
{_ingest.timestamp}}"
}
}
]
}
2、添加索引
#先创建索引
#语法:PUT /索引名
PUT /transactionmonitor-2021.12.15
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
}
#在设置字段类型(es6.x版本)
#语法:PUT /索引库名/_mapping/类型名称
PUT /transactionmonitor-2021.12.15/_mapping/doc
{
"properties": {
"code": {
"type": "text",
"fields