Skip to content

The date_index_name processor calculates wrong week if index_name_format is 'yyyy-w' #41670

Closed
@yoogie

Description

@yoogie

Elasticsearch version (bin/elasticsearch --version):
Version: 7.0.0, Build: default/zip/b7e28a7/2019-04-05T22:55:32.697037Z, JVM: 1.8.0_121

Plugins installed: []

JVM version (java -version):
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

OS version (uname -a if on a Unix-like system):
win7

Description of the problem including expected versus actual behavior:
Indexing a document using the date_index_name processor with "date_rounding" : "d" and "index_name_format": "yyyy-w" indexes the time 2017-12-04T17:00:58.580 in a index named x-2017-1 while expected index name would be x-2017-49

Steps to reproduce:

PUT _ingest/pipeline/testingestpipeline
{
  "description": "Pipeline for routing data to specific index by createtime",
  "processors": [
    {
      "date": {
        "field": "createdTime",
        "formats": [
          "date_time","date_time_no_millis", "date_hour_minute_second_millis", "date_hour_minute_second_fraction"
        ]
      },
      "date_index_name": {
        "field": "@timestamp",
        "date_rounding": "d",
        "index_name_prefix": "x-",
        "index_name_format": "yyyy-w"
      }
    }
  ]
}
DELETE x-*

PUT x-test/_doc/1?pipeline=testingestpipeline
{
  "createdTime": "2017-12-04T17:00:58.580"
}

Index name -> x-2017-1

If using index_name_format including month and day, the week gets correct

PUT _ingest/pipeline/workingingestpipeline
{
  "description": "Pipeline for routing data to specific index by createtime",
  "processors": [
    {
      "date": {
        "field": "createdTime",
        "formats": [
          "date_time","date_time_no_millis", "date_hour_minute_second_millis", "date_hour_minute_second_fraction"
        ]
      },
      "date_index_name": {
        "field": "@timestamp",
        "date_rounding": "d",
        "index_name_prefix": "x-",
        "index_name_format": "yyyy-MM-dd-w"
      }
    }
  ]
}
DELETE x-*

PUT x-test/_doc/1?pipeline=workingingestpipeline
{
  "createdTime": "2017-12-04T17:00:58.580"
}

Index name -> x-2017-12-04-49

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions