Kibana Query DSL Sorting and size does not work

Hi , how to make sorting works in kibana Query DSL . i am using the following script.

I don't believe you can sort via that method. The column headers have small triangle buttons can be used to sort the entries.

i am surprised why elastic search query's with sorting ,ranges dont work at this Query DSL . same works fine if i run in dev tools . We need to show the this results in kibana charts

What visualizations are you using? There are likely some sorting controls within the visualizations you want to use. Discover is it's own kind of visualization/app - just because you can't sort with a script inside it, doesn't mean other visualizations can't.

Discover is doing a lot of work under the covers, constructing the query that ultimately displays the documents. It gets the sort order to use via the column header sort buttons (small triangles). It would get confusing if you could sort two different ways.

i would like add a search panel on dashboard , which should limit the results to latest 5 .now in the this screen shot it shows all . i used search query and added a size attribute but it just ignored. is there any other visualization that i can achieve each entry in a row ?