How to remove duplicate search result in elasticsearch?

I use a paginated search by elasticseach. But the items are duplicated between pages. It is at the bottom of this page and at the top of the other page.
I did like this but it still doesn't work
$aggregations = [
"unique_id"=>[
"terms"=>[
"field"=>"id"
]
]
];
Is there a way to solve this problem?

Is it happening because you are still indexing new data while going from one page to another?

right. I have that problem

Is it true if I use it like this?
$aggregations = [
"dedup"=>[
"terms"=>[
"field"=>"id"
]
]
];

So in the next 7.10 version, you will be able to use the new Point In Time API.

For now, you can use the scroll API but it does not have the same "flexibility" of the new API as you can just move forward and not backward. See