How to take only last 20 records of the document in Visualization?

I want to count of hits w.r.t the datetime in visualization but while I use visualization tool to build the chart It applies on the whole document.

So when I plot the data with 10 objects (size of the bucket) in Asc order it sorts from the whole document and plots it bellow is the screen shot

And if I sort it in Desc order it applies on the whole document and shows such result

Hence I am not able to fetch todays records.

Please help
Thanks and Regards

Hi there,

if you want that type of graph you don't need a Terms aggregation but a Date Histogram aggregation on a date type field.