Skip to content

Add support for key_as_string for term aggregation #836

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

Closed
ppf2 opened this issue Jul 31, 2014 · 6 comments
Closed

Add support for key_as_string for term aggregation #836

ppf2 opened this issue Jul 31, 2014 · 6 comments
Labels

Comments

@ppf2
Copy link
Member

ppf2 commented Jul 31, 2014

The REST API term aggregation returns key_as_string as a "friendly" timestamp in addition to key (epoch time) in the response. But key_as_string is getting skipped in NEST. Would be nice to add key_as_string to KeyItem so that it can be retrieved as a field from KeyItem along with Key and DocCount.

"aggregations": {
      "test": {
         "buckets": [
            {
               "key": 1373814509000,
               "key_as_string": "2013-07-14T15:08:29.000Z",
               "doc_count": 1
            },
            {
               "key": 1371222509000,
               "key_as_string": "2013-06-14T15:08:29.000Z",
               "doc_count": 1
            }
         ]
      }
   } 
@ppf2
Copy link
Member Author

ppf2 commented Jul 31, 2014

Actually, will help further if we provide a way to return the key value as a .net DateTime object.

@gmarz
Copy link
Contributor

gmarz commented Jul 31, 2014

@ppf2, the reason for skipping key_as_string is to keep backwards compatibility with earlier versions of ES where that property doesn't exist. See #730 for some background.

I agree we should support key_as_string and handle this better. I'm also +1 for providing a way to retrieve the key as a DateTime object (if it is one).

Thanks for reporting this!

@gmarz
Copy link
Contributor

gmarz commented Jul 31, 2014

@ppf2 I just pushed 8505c4f which adds support for key_as_string.

@gmarz gmarz added this to the NEST 1.1 milestone Jul 31, 2014
@ppf2
Copy link
Member Author

ppf2 commented Jul 31, 2014

@gmarz thx!

@gmarz
Copy link
Contributor

gmarz commented Jul 31, 2014

@ppf2 no problem.

Also, on second thought, in regards to providing a way to retrieve a key as DateTime, I think it might be best to leave that up to the user. The problem is that a key could be other values other than a date (numeric, text) and NEST shouldn't make any assumptions.

What do you think?

@gmarz
Copy link
Contributor

gmarz commented Aug 5, 2014

@ppf2 closing this unless you have any objections to the above. Feel free to re-open if so.

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

No branches or pull requests

2 participants