Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show proper date format in response on max aggregation over timestamp #6812

Closed
stha opened this issue Jul 10, 2014 · 2 comments · Fixed by #9032
Closed

Show proper date format in response on max aggregation over timestamp #6812

stha opened this issue Jul 10, 2014 · 2 comments · Fixed by #9032
Assignees
Labels

Comments

@stha
Copy link

stha commented Jul 10, 2014

If you currently do a max aggregation on a date field, elasticsearch prints the output as a unix timestamp including milliseconds.

Example request:

{
...
"aggregations": {
    "last_hit": {
      "max": {
        "field": "@timestamp"
      }
    }
  }
...
}

Example current response:

{
...
 "aggregations": {
      "last_hit": {
         "value": 1404196200000
      }
   }
...
}

It would be more preferable if the output would be given in the following format:

Improved response:

{
...
 "aggregations": {
      "last_hit": {
         "value": "01.07.2014T06:30:00.000Z"
      }
   }
...
}
@antong
Copy link

antong commented Sep 10, 2014

I also got hit by this. Of course it feels like an unnecessary chore to decode what is left after max("2014-09-10T19:04:19.725694", "2014-09-10T11:12:13.432432") -> 1410375855.35215. However, the _source of the compared docs may have many different formats for the time stamp. So what should the result format be for max("2014-09-10T19:04:19.725694", 1410375055.1234, ...)?

If a string format is implemented, IMHO it must be ISO format without time zone and nothing else.

UPDATE/EDIT: Oh, with including milliseconds it means that the value is like UTC-milliseconds since UNIX epoch. Which really is surprising for the user. I first thought it really was a UNIX timestamp.

@bly2k
Copy link
Contributor

bly2k commented Sep 30, 2014

Perhaps adding a format specifier just like in the date_histogram agg? I do agree this is a nice and useful feature to have.

{
"aggregations": {
    "last_hit": {
      "max": {
        "field": "@timestamp",
        "format": "YYYY-MM-dd"
      }
    }
  }
}

@clintongormley clintongormley added help wanted adoptme and removed discuss labels Oct 31, 2014
@colings86 colings86 removed the help wanted adoptme label Dec 22, 2014
@colings86 colings86 self-assigned this Dec 22, 2014
colings86 added a commit that referenced this issue Jan 9, 2015
You can now specify `format` in the request definition for most numeric metric aggregations. The exceptions are Percentile_Ranks, Cardinality and Value_Count as the response type of these can be different from the field type so the formatter won't work.

Closes #6812
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants