# Search\_after still gives me duplicates

**URL:** https://discuss.elastic.co/t/search-after-still-gives-me-duplicates/343861
**Category:** Elasticsearch
**Tags:** elastic-stack-sql
**Created:** [September 26, 2023, 11:07am UTC](https://discuss.elastic.co/t/search-after-still-gives-me-duplicates/343861 "2023-09-26T11:07:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![George\_Githinji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/george_githinji/32/124998_2.png) [@George\_Githinji](https://discuss.elastic.co/u/George_Githinji)
#### Post date: [September 26, 2023, 11:07am UTC](https://discuss.elastic.co/t/search-after-still-gives-me-duplicates/343861/1 "2023-09-26T11:07:27Z")

</div>

Hi, I have implemented a search-after pattern in my Elasticsearch implementation with a hope of solving duplicate issue we are currently facing. On the first request, I am getting a batch of 100 and then get the raw\_score and id.keyword of the last result and then use it to query the next batch using search\_after pattern. So I am getting search batch 1-2-3-4 and then paging backward from 4-3-2-1. So after making a complete round i.e 1-2-3-4 and 4-3-2-1 and then try to make another query 1-2-3-4, I am getting some results in 2 that are already in 1. What could be causing the duplicates, yet search of batch 2 is searched using the search\_after parameters for the last result in batch 1?

I followed this guide [here](https://opster.com/guides/elasticsearch/how-tos/elasticsearch-pagination-techniques/)

---

<div class="post-metadata">

### Author: ![Alex\_Salgado-Elastic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_salgado-elastic/32/103081_2.png) [@Alex\_Salgado-Elastic](https://discuss.elastic.co/u/Alex_Salgado-Elastic)
#### Post date: [September 26, 2023, 1:22pm UTC](https://discuss.elastic.co/t/search-after-still-gives-me-duplicates/343861/2 "2023-09-26T13:22:32Z")

</div>

Hi @George_Githinji ,

Could you provide the query code here?

Thanks,  
Alex

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 24, 2023, 1:22pm UTC](https://discuss.elastic.co/t/search-after-still-gives-me-duplicates/343861/3 "2023-10-24T13:22:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
