Can I create a histogram of ages based on birthdates?

Hello.
I have an index populated with people and their birth dates. I want to
create a histogram of their current ages. Is this possible?

So I have tried using a date histogram aggregation with year interval which
gives me what years the users where born. This is a good start. To get
exact ages I thought I could use the pre/post offset. Is this correct?
I use the java client and calculate the number of milliseconds that have
passes since the beginning of the year and pass that into the pre/post
offset but I always get a null response when doing this. The entire request
fails. If I remove the offsets the request passes again. Have I
misunderstood something? Is it possible to use the date histogram to
achieve what I want?

Thanks
/Ludwig

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/070a6e31-4e03-4899-b566-941012d0ae9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

This should be possible to do using script fields:

However, you will need to figure out how to do date manipulation there

--

Itamar Syn-Hershko
http://code972.com | @synhershko https://twitter.com/synhershko
Freelance Developer & Consultant
Author of RavenDB in Action http://manning.com/synhershko/

On Mon, May 5, 2014 at 1:34 PM, Ludwig Magnusson <ludwig.magnusson@gmail.com

wrote:

Hello.
I have an index populated with people and their birth dates. I want to
create a histogram of their current ages. Is this possible?

So I have tried using a date histogram aggregation with year interval
which gives me what years the users where born. This is a good start. To
get exact ages I thought I could use the pre/post offset. Is this correct?
I use the java client and calculate the number of milliseconds that have
passes since the beginning of the year and pass that into the pre/post
offset but I always get a null response when doing this. The entire request
fails. If I remove the offsets the request passes again. Have I
misunderstood something? Is it possible to use the date histogram to
achieve what I want?

Thanks
/Ludwig

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/070a6e31-4e03-4899-b566-941012d0ae9b%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/070a6e31-4e03-4899-b566-941012d0ae9b%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAHTr4ZuiD-PvORm3Dgu3vOwD%2Bw3spc-X7jKLQC%2BkDrxFt4aeqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.