Force date format in context query (#22684) (#22826)

Fixes issue reported in https://discuss.elastic.co/t/view-surrounding-documents-causes-failed-to-parse-date-field-exception/147234

The default date field format is `strict_date_optional_time||epoch_millis`
so we didn't run into this during testing. If the user has custom
mappings for their timestamp field and `epoch_millis` isn't one of the
optional formats the context query will fail since it always sends the
date in millis. This change forces the query to accept the date in millis.
This commit is contained in:
Matt Bargar 2018-09-07 17:34:12 -04:00 committed by GitHub
parent 108b524ae8
commit a9f06c0595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View file

@ -103,7 +103,7 @@ describe('context app', function () {
// should have started at the given time
expect(intervals[0].gte).to.eql(MS_PER_DAY * 3000);
// should have ended with a half-open interval
expect(_.last(intervals)).to.only.have.key('gte');
expect(_.last(intervals)).to.only.have.keys('gte', 'format');
expect(intervals.length).to.be.greaterThan(1);
expect(hits).to.eql(searchSourceStub._stubHits.slice(0, 3));

View file

@ -103,7 +103,7 @@ describe('context app', function () {
// should have started at the given time
expect(intervals[0].lte).to.eql(MS_PER_DAY * 3000);
// should have ended with a half-open interval
expect(_.last(intervals)).to.only.have.key('lte');
expect(_.last(intervals)).to.only.have.keys('lte', 'format');
expect(intervals.length).to.be.greaterThan(1);
expect(hits).to.eql(searchSourceStub._stubHits.slice(-3));

View file

@ -216,6 +216,7 @@ function fetchContextProvider(indexPatterns, Private) {
filter: {
range: {
[timeField]: {
format: 'epoch_millis',
...startRange,
...endRange,
}