Skip to content

Commit

Permalink
Issue #22: enable sort on _doc
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Nov 23, 2023
1 parent e2264b8 commit 5a5e25f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions pkg/quickwit/data_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa
sort = es.SortOrderAsc
}
b.Sort(sort, defaultTimeField, "boolean")
// FIXME: check if sort by _doc is needed.
// b.Sort(sort, "_doc", "")
b.Sort(sort, "_doc", "")
b.Size(stringToIntWithDefaultValue(metric.Settings.Get("limit").MustString(), defaultSize))
// TODO when hightlight is supported in quickwit
// b.AddHighlight()
Expand All @@ -352,7 +351,7 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa
func processDocumentQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defaultTimeField string) {
metric := q.Metrics[0]
b.Sort(es.SortOrderDesc, defaultTimeField, "boolean")
// b.Sort(es.SortOrderDesc, "_doc", "")
b.Sort(es.SortOrderDesc, "_doc", "")
// Note: not supported in Quickwit
// b.AddDocValueField(defaultTimeField)
b.Size(stringToIntWithDefaultValue(metric.Settings.Get("size").MustString(), defaultSize))
Expand Down
1 change: 1 addition & 0 deletions pkg/quickwit/response_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func processLogsResponse(res *es.SearchResponse, target *Query, configuredFields

doc := map[string]interface{}{
"_source": flattened,
"sort": hit["sort"],
}

for k, v := range flattened {
Expand Down
4 changes: 2 additions & 2 deletions pkg/quickwit/response_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func TestProcessLogsResponse(t *testing.T) {
require.Len(t, dataframes, 1)
frame := dataframes[0]

require.Equal(t, 11, len(frame.Fields))
require.Equal(t, 12, len(frame.Fields))
// Fields have the correct length
require.Equal(t, 2, frame.Fields[0].Len())
// First field is timeField
Expand All @@ -324,7 +324,7 @@ func TestProcessLogsResponse(t *testing.T) {
require.Equal(t, "nested.field.double_nested", frame.Fields[8].Name)
require.Equal(t, data.FieldTypeNullableString, frame.Fields[8].Type())
// Correctly detects type even if first value is null
require.Equal(t, data.FieldTypeNullableString, frame.Fields[10].Type())
require.Equal(t, data.FieldTypeNullableJSON, frame.Fields[10].Type())
})
}

Expand Down

0 comments on commit 5a5e25f

Please sign in to comment.