Skip to content

Commit

Permalink
Fix: convert nano to ms and add searchAfter param
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Nov 22, 2023
1 parent d3a1c8d commit 8caca9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/quickwit/data_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa
b.Size(stringToIntWithDefaultValue(metric.Settings.Get("limit").MustString(), defaultSize))
// TODO when hightlight is supported in quickwit
// b.AddHighlight()

// This is currently used only for log context query to get
// log lines before and after the selected log line
searchAfter := metric.Settings.Get("searchAfter").MustArray()
for _, value := range searchAfter {
b.AddSearchAfter(value)
}
}

func processDocumentQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defaultTimeField string) {
Expand Down
4 changes: 3 additions & 1 deletion src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ export class QuickwitDataSource

private makeLogContextDataRequest = (row: LogRowModel, options?: LogRowContextOptions) => {
const direction = options?.direction || LogRowContextQueryDirection.Backward;
const searchAfterNs = row.dataFrame.fields.find((f) => f.name === 'sort')?.values.get(row.rowIndex) ?? [row.timeEpochNs]
const searchAfterMs = [Math.round(searchAfterNs[0]/1000000)]

const logQuery: Logs = {
type: 'logs',
Expand All @@ -445,7 +447,7 @@ export class QuickwitDataSource
// Sorting of results in the context query
sortDirection: direction === LogRowContextQueryDirection.Backward ? 'desc' : 'asc',
// Used to get the next log lines before/after the current log line using sort field of selected log line
searchAfter: row.dataFrame.fields.find((f) => f.name === 'sort')?.values.get(row.rowIndex) ?? [row.timeEpochMs],
searchAfter: searchAfterMs,
},
};

Expand Down

0 comments on commit 8caca9f

Please sign in to comment.