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

Bad date range filter when filtering non-timefield date fields #6338

Closed
feicipet opened this issue Feb 26, 2016 · 6 comments
Closed

Bad date range filter when filtering non-timefield date fields #6338

feicipet opened this issue Feb 26, 2016 · 6 comments
Assignees
Labels
bug Fixes for quality problems that affect the customer experience

Comments

@feicipet
Copy link

Hi,

I'm using Kibana version 4.4.1 with ES 2.2.0 from the Debian repos.

I have a field with the following type defined:

            "InvitationTime" : {
                "type" : "date",
                "format" : "dd/MM/yyyy HH:mm:ss Z"
            }

I created a data table visualization with a date histogram aggregation on this field:

kibana-agg02

When I click on one of the dates to filter though, I get an error where it tries to parse the millis-since-epoch value of the field in my field format:

kibana-agg03

Is this a bug or am I doing something wrong?

Thanks
Wong

@rashidkpc
Copy link
Contributor

Legit bug

It looks like we aren't passing the format when creating range filters that use a date field. Now that Elasticsearch no longer accepts epoch by default we'll need to check if the field is a date, and if it is we need to tell it we're supplying epoch millis

This happens when creating a date_histogram agg on date field which is not the timefield for the index pattern.

screen shot 2016-02-29 at 3 16 08 pm

Here's how we fix this:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#_date_format_in_range_queries

@rashidkpc rashidkpc added bug Fixes for quality problems that affect the customer experience P1 labels Feb 29, 2016
@rashidkpc rashidkpc changed the title Error parsing date histogram filter in visualization Bad date range filter when filtering non-timefield date fields Feb 29, 2016
@feicipet
Copy link
Author

feicipet commented Mar 2, 2016

Thanks Rashid.

FWIW, I've found a workaround by specifying the format of the date field as follows:

        "ProcessDatetime" : {
            "type" : "date",
            "format" : "dd/MM/yyyy HH:mm:ss Z||epoch_millis"
        },

May be useful for anyone who's facing this issue while we wait for a fix.

Rashid, if you can explain why this "fixes" the problem, it'd be really educational for me :) I roughly surmised that doing this would allow ES to accept two formats of input but not sure if I'm right on that.

@ycombinator ycombinator self-assigned this May 3, 2016
@ycombinator
Copy link
Contributor

Rashid, if you can explain why this "fixes" the problem, it'd be really educational for me :) I roughly surmised that doing this would allow ES to accept two formats of input but not sure if I'm right on that.

@feicipet Hi, as described in https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html#multiple-date-formats, the || separator tells Elasticsearch to try various formats, one after the other, when parsing the string in the field as a timestamp. In your workaround, Elasticsearch first tries to parse the integer in Kibana's range filter request using the first format for your field, dd/MM/yyyy HH:mm:ss Z. When that doesn't work, it tries parsing it using the next format, epoch_millis, which succeeds.

As you noted this is a workaround; the real fix ought to be on Kibana's end as Rashid noted in his comment above.

@dimileeh
Copy link

dimileeh commented Aug 3, 2016

This issue still doesn't seem to have been fixed in Kibana 4.5. As suggested by @feicipet, I had to add ||epoch_millis format for the date field in the index template to make Kibana apply the filters correctly when I click on a range in the histogram.

@ycombinator
Copy link
Contributor

Hi @dlihhats, the issue has been fixed in Kibana 5. So you will need to upgrade to it to get the fix. Currently Kibana 5 is in an alpha release, which you can download from here: https://www.elastic.co/downloads/kibana (scroll down the page or search for "alpha").

@ddrake17
Copy link

This is broken again in the latest Kibana 6.1.2 I used the work around as suggested by @feicipet and it is working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience
Projects
None yet
Development

No branches or pull requests

6 participants