Elasticsearch: Run log context queries through backend (#65805)
* Elasticsearch: Run context queries trough backend * Fix typing * Update * Add possibility to run context query torugh backend and frontend * Correctly sort
This commit is contained in:
@@ -1354,6 +1354,25 @@ func TestExecuteElasticsearchDataQuery(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("With log context query with sortDirection and searchAfter should return correct query", func(t *testing.T) {
|
||||
c := newFakeClient()
|
||||
_, err := executeElasticsearchDataQuery(c, `{
|
||||
"metrics": [{ "type": "logs", "id": "1", "settings": { "limit": "1000", "sortDirection": "asc", "searchAfter": [1, "2"] }}]
|
||||
}`, from, to)
|
||||
require.NoError(t, err)
|
||||
sr := c.multisearchRequests[0].Requests[0]
|
||||
require.Equal(t, sr.Sort["@timestamp"], map[string]string{"order": "asc", "unmapped_type": "boolean"})
|
||||
require.Equal(t, sr.Sort["_doc"], map[string]string{"order": "asc"})
|
||||
|
||||
searchAfter := sr.CustomProps["search_after"].([]interface{})
|
||||
firstSearchAfter, err := searchAfter[0].(json.Number).Int64()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, firstSearchAfter, int64(1))
|
||||
secondSearchAfter := searchAfter[1].(string)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, secondSearchAfter, "2")
|
||||
})
|
||||
|
||||
t.Run("With invalid query should return error", (func(t *testing.T) {
|
||||
c := newFakeClient()
|
||||
_, err := executeElasticsearchDataQuery(c, `{
|
||||
|
||||
Reference in New Issue
Block a user