Tự động thêm thời gian tạo bản ghi Elasticsearch

Chạy lệnh sau để mỗi khi dùng pipeline timestamp thì tự động có thể thông tin created date

PUT _ingest/pipeline/timestamp
{
  "description": "Adds timestamp to documents",
  "processors": [
    {
      "set": {
        "field": "_source.created_time",
        "value": "{{_ingest.timestamp}}"
      }
    }
  ]
}

Sau đó chạy lệnh sau để test

POST my-index-000001/_doc?pipeline=timestamp
{
  "user": {
    "id": "kimchy"
  }
}

GET /my-index-000001/_search
{
  "query":{
    "match_all":{}
  }
}

Kết quả:

Leave a Reply

Your email address will not be published. Required fields are marked *