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

fixes error with custom interval in datetime aggregation #9427

Closed
wants to merge 2 commits into from

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Dec 9, 2016

fixes error with custom interval in datetime aggregation with values like 2w

closes #9184

@ppisljar ppisljar added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review v5.2.0 v6.0.0 labels Dec 9, 2016
@thomasneirynck thomasneirynck self-assigned this Dec 13, 2016
@thomasneirynck
Copy link
Contributor

jenkins, test this

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM:

Likely due to elastic/elasticsearch#19102 in the first place.

@@ -3,7 +3,7 @@ import dateMath from '@elastic/datemath';
export default function () {

const unitsDesc = dateMath.unitsDesc;
const largeMax = unitsDesc.indexOf('M');
const largeMax = unitsDesc.indexOf('w');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some explanation here, since this is somewhat of a magic number.

@thomasneirynck
Copy link
Contributor

this probably needs rebasing as well.

@ppisljar
Copy link
Member Author

jenkins, test this

@tbragin
Copy link
Contributor

tbragin commented Dec 15, 2016

Functional LGTM

@kobelb
Copy link
Contributor

kobelb commented Dec 21, 2016

The docs state, that the Date Histogram aggregation uses the time-units for the interval in addition to: year, quarter, month, week, day, hour, minute, second

However, it appears that the following undocumented values are also valid for the interval: 1y, 1q, 1M, 1w, 1d, 1h, 1m, 1s per https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java#L64. So, that's why 1w works, and 2w doesn't when querying Elasticsearch. 1w is a hard-coded and undocumented value that takes effect before falling back to the 'time-units'.

@kobelb
Copy link
Contributor

kobelb commented Dec 21, 2016

It might be helpful to document why we're limiting the "large units" from being anything but 1, as it's using undocumented values that on first glance appear to be invalid.

Or, it might be prudent to not rely on the undocumented values.

@ppisljar
Copy link
Member Author

@epixa @spalger @Bargs what are your opinions, what direction should we take this ?

  • go further with this PR, update documentation
  • dont go further with this PR, change behaviour to not accept undocumented time arguments, handle error correctly
  • dont go further with this PR, update documentation to describe all working time arguments, handle error correctly ?
  • something else ?

@Bargs
Copy link
Contributor

Bargs commented Dec 21, 2016

Supporting those undocumented values seems like it could only lead to confusion for the user, particularly because they look so similar to the "time-units" Brandon mentioned. I wouldn't rely on them personally.

However I'd also check with the ES team to see what's up with these mystery values. Perhaps they could add week support to time-units and start throwing errors for these undocumented values.

Alternatively, and this might be the best approach but the most work, you could define a set of valid interval values in kibana, and then translate them into some valid, lowest common denominator unit for ES. e.g. 2 weeks becomes 1209600000 milliseconds

@ppisljar
Copy link
Member Author

this is not the right approach, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review v6.0.0-rc1 v6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weekly aggregation interval in date histogram aggregation causes error
6 participants