Skip to content

Commit

Permalink
Switch from _source to fields for anchor date_nanos ts retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Jan 7, 2020
1 parent 9aa2341 commit fc0f2f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ function fetchContextProvider(indexPatterns: IndexPatternsContract) {
const searchSource = await createSearchSource(indexPattern, filters);
const sortDirToApply = type === 'successors' ? sortDir : reverseSortDir(sortDir);

const nanos = indexPattern.isTimeNanosBased() ? extractNanos(anchor._source[timeField]) : '';
const nanos = indexPattern.isTimeNanosBased() ? extractNanos(anchor.fields[timeField][0]) : '';
const timeValueMillis =
nanos !== '' ? convertIsoToMillis(anchor._source[timeField]) : anchor.sort[0];
nanos !== '' ? convertIsoToMillis(anchor.fields[timeField][0]) : anchor.sort[0];

const intervals = generateIntervals(LOOKUP_OFFSETS, timeValueMillis, type, sortDir);
let documents: EsHitRecordList = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export function getEsQuerySearchAfter(
const afterTimeRecIdx = type === 'successors' && documents.length ? documents.length - 1 : 0;
const afterTimeDoc = documents[afterTimeRecIdx];
const afterTimeValue = nanoSeconds
? convertIsoToNanosAsStr(afterTimeDoc._source[timeFieldName])
? convertIsoToNanosAsStr(afterTimeDoc.fields[timeFieldName][0])
: afterTimeDoc.sort[0];
return [afterTimeValue, afterTimeDoc.sort[1]];
}
// if data_nanos adapt timestamp value for sorting, since numeric value was rounded by browser
// ES search_after also works when number is provided as string
return [
nanoSeconds ? convertIsoToNanosAsStr(anchor._source[timeFieldName]) : anchor.sort[0],
nanoSeconds ? convertIsoToNanosAsStr(anchor.fields[timeFieldName][0]) : anchor.sort[0],
anchor.sort[1],
];
}

0 comments on commit fc0f2f2

Please sign in to comment.