Skip to content

[ES|QL] TOP(..., 1, ...) ignores WHERE clause #134293

@jan-elastic

Description

@jan-elastic

Elasticsearch Version

main

Installed Plugins

No response

Java Version

n/a

OS Version

n/a

Problem Description

The following ES|QL query gives incorrect results:

ROW x = [1,2,3,4] 
  | MV_EXPAND x
  | STATS top1 = TOP(x, 1, "ASC") WHERE x==3,
          top2 = TOP(x, 2, "ASC") WHERE x==3,
          min  = MIN(x) WHERE x==3

The three aggs should give the same result (3), however the results are:

     top1      |     top2      |      min      
---------------+---------------+---------------
1              |3              |3         

Note that:

  • top2 is effectively the same as top1 here and correctly works
  • top1 has min as surrogate, however something goes wrong there
  • min itself is correct

Steps to Reproduce

see above

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions