**What is the bug?** PPL query: ``` source=employees | eval a = rand() | sort a | fields id | head 5 ``` returns rows more than 5. **How can one reproduce the bug?** Steps to reproduce the behavior: 1. Put documents more than the head limiation ``` POST localhost:9200/{{index}}/_bulk {"index":{"_id":"1"}} {"id":1,"name":"Dev","reportsTo":"Eliot"} {"index":{"_id":"2"}} {"id":2,"name":"Eliot","reportsTo":"Ron"} {"index":{"_id":"3"}} {"id":3,"name":"Ron","reportsTo":"Andrew"} {"index":{"_id":"4"}} {"id":4,"name":"Andrew","reportsTo":null} {"index":{"_id":"5"}} {"id":5,"name":"Asya","reportsTo":"Ron"} {"index":{"_id":"6"}} {"id":6,"name":"Dan","reportsTo":"Andrew"} ``` 2. Query using above query ``` source=employees | eval a = rand() | sort a | fields id | head 5 ``` It return all 6 rows. **What is the expected behavior?** Should return 5 rows. **What is your host/environment?** - OS: MacOs - Version 3.5.0-SNAPSHOT - Plugins **Do you have any screenshots?** If applicable, add screenshots to help explain your problem. **Do you have any additional context?** Add any other context about the problem.
Activity
Fix opensearch-project#5114: preserve head/TopK semantics for sort-ex…
Address comments in pr:5138 (#5179)