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

Aggregated Buckets return unexpected results when post_zone and min_doc_count =0 are passed #71

Closed
amitpandita opened this issue Feb 16, 2015 · 4 comments

Comments

@amitpandita
Copy link

Dear Honza/ ES Team,

I am getting weird results when i use date_histogram aggregation along with various params such as pos_zone and min_doc_count=0 and it breaks on the Feb month and instead of returning the result from the 1st of the month it returns 28th of March instead of 31st.

s = Search(using=es).index(settings.ES_INDEX).doc_type("my_doc_type")
s = s.filter('range',date_field = {"from": date(2014,11,1)})
s.aggs.bucket('ranges', 'date_histogram', field='date_field', interval='month',post_zone="-5:30",min_doc_count=0)

{u'ranges': {u'buckets': [{u'doc_count': 143,
u'key': 1414780200000,
u'key_as_string': u'2014-10-31T18:30:00.000Z'},
{u'doc_count': 654,
u'key': 1417372200000,
u'key_as_string': u'2014-11-30T18:30:00.000Z'},
{u'doc_count': 0,
u'key': 1419964200000,
u'key_as_string': u'2014-12-30T18:30:00.000Z'},
{u'doc_count': 1494,
u'key': 1420050600000,
u'key_as_string': u'2014-12-31T18:30:00.000Z'},
{u'doc_count': 968,
u'key': 1422729000000,
u'key_as_string': u'2015-01-31T18:30:00.000Z'},
{u'doc_count': 0,
u'key': 1425148200000,
u'key_as_string': u'2015-02-28T18:30:00.000Z'},

Please look at the December month buckets.

Please let me know if i am doing something wrong here.

@honzakral
Copy link
Contributor

I cannot see anything you are doing wrong here, seems to be a bug in Elasticsearch itself. Could you produce a minimal script that replicates this issue so we can file a ticket for elasticsearch? Thanks!

@amitpandita
Copy link
Author

Hi Honza,

Please find the script below:

from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
from datetime import date

es = Elasticsearch()

s = Search(using = es).index('index_name').doc_type('doc_type_name')

s = s.filter('range',date_field = {"from": date(2014,11,1)})

s.aggs.bucket('ranges', 'date_histogram', field='date_field', interval='month',post_zone="-5:30",min_doc_count=0)

r = s.execute()

r.aggregations.ranges.buckets

@cbuescher
Copy link
Member

Hi,
this looks very similar to an open issue we have here:
elastic/elasticsearch#7673

@honzakral
Copy link
Contributor

yes, closing this since this is an Elasticsearch issue outside of python. Thanks for the report.

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

No branches or pull requests

3 participants