# Duplicated records returned using pagination after update

**URL:** https://discuss.elastic.co/t/duplicated-records-returned-using-pagination-after-update/12912
**Category:** Elasticsearch
**Created:** [July 23, 2013, 11:10pm UTC](https://discuss.elastic.co/t/duplicated-records-returned-using-pagination-after-update/12912 "2013-07-23T23:10:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jak\_Charlton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jak_charlton/32/2226_2.png) [@Jak\_Charlton](https://discuss.elastic.co/u/Jak_Charlton)
#### Post date: [July 23, 2013, 11:10pm UTC](https://discuss.elastic.co/t/duplicated-records-returned-using-pagination-after-update/12912/1 "2013-07-23T23:10:28Z")

</div>

I'm using v0.90.0 of ES, and I just implemented pagination.

All was going fine until I updated one of my records, then I noticed that  
the returned results had a record duplicated. Update another record and a  
new duplicate.

The number of records did not increased, just one record was lost from the  
index and replaced with a duplicate (the duplicate was a perfect duplicate  
including the ID of the original).

The duplicate only appears when querying with from/size ... a google search  
seems to have a few people having a similar problem, but no suggested  
answers/solutions [http://goo.gl/Y989w6](http://goo.gl/Y989w6)

_Asking for size 10, returns all 10 records correctly:_

➜ chimp git:(array-tags) ✗ curl -X GET  
'[http://localhost:9200/people/person/\_search?pretty](http://localhost:9200/people/person/_search?pretty)' -d  
'{"sort":[{"first\_name":"asc"}],"filter":{"term":{"machine\_id":58}},"size":10,"from":0}'  
{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 10,  
"max\_score" : null,  
"hits" : [ {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "107",  
"\_score" : null, "\_source" :  
{"id":107,"first\_name":"BANANA","last\_name":"asdasd","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["banana"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "106",  
"\_score" : null, "\_source" :  
{"id":106,"first\_name":"CABBAGE","last\_name":"asd","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["cabbage"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "114",  
"\_score" : null, "\_source" :  
{"id":114,"first\_name":"DAVE","last\_name":"JONES","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":["asdasd","asdasdad","red","HELLO","HELLO","blue  
fruits"]},  
"sort" : ["dave"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "115",  
"\_score" : null, "\_source" :  
{"id":115,"first\_name":"ERIC","last\_name":"","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["eric"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "103",  
"\_score" : null, "\_source" :  
{"id":103,"first\_name":"GRETA","last\_name":"Man","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["greta"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "102",  
"\_score" : null, "\_source" :  
{"id":102,"first\_name":"Jack","last\_name":"Jones","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["jack"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "100",  
"\_score" : null, "\_source" :  
{"id":100,"first\_name":"NAME","last\_name":"asd","machine\_id":58,"email":"test@testme.com","website":"","telephone\_number":"","tags":[]},  
"sort" : ["name"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "111",  
"\_score" : null, "\_source" :  
{"id":111,"first\_name":"NAME","last\_name":"asdasdasd","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["name"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "108",  
"\_score" : null, "\_source" :  
{"id":108,"first\_name":"PEANUT","last\_name":"asdsd","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["peanut"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "104",  
"\_score" : null, "\_source" :  
{"id":104,"first\_name":"WillX","last\_name":"SmithX","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":["hello","red"]},  
"sort" : ["willx"]  
} ]  
}  
}%

_Asking for 5 records returns 5 records, but the updated record ("GRETA")  
in the query above is missing (they are sorted by first\_name so it should  
be there)_

➜ chimp git:(array-tags) ✗ curl -X GET  
'[http://localhost:9200/people/person/\_search?pretty](http://localhost:9200/people/person/_search?pretty)' -d  
'{"sort":[{"first\_name":"asc"}],"filter":{"term":{"machine\_id":58}},"size":5,"from":0}'  
{  
"took" : 1,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 10,  
"max\_score" : null,  
"hits" : [ {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "107",  
"\_score" : null, "\_source" :  
{"id":107,"first\_name":"BANANA","last\_name":"asdasd","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["banana"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "106",  
"\_score" : null, "\_source" :  
{"id":106,"first\_name":"CABBAGE","last\_name":"asd","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["cabbage"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "114",  
"\_score" : null, "\_source" :  
{"id":114,"first\_name":"DAVE","last\_name":"JONES","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":["asdasd","asdasdad","red","HELLO","HELLO","blue  
fruits"]},  
"sort" : ["dave"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "115",  
"\_score" : null, "\_source" :  
{"id":115,"first\_name":"ERIC","last\_name":"","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["eric"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "102",  
"\_score" : null, "\_source" :  
{"id":102,"first\_name":"Jack","last\_name":"Jones","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["jack"]  
} ]  
}  
}%

_Asking for the next page has "Jack Jones" effectively duplicated (he was  
pulled into the first page of results incorrectly as GRETA was missing, but  
he is correctly in this page:_

chimp git:(array-tags) ✗ curl -X GET  
'[http://localhost:9200/people/person/\_search?pretty](http://localhost:9200/people/person/_search?pretty)' -d  
'{"sort":[{"first\_name":"asc"}],"filter":{"term":{"machine\_id":58}},"size":5,"from":4}'  
{  
"took" : 1,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 10,  
"max\_score" : null,  
"hits" : [ {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "102",  
"\_score" : null, "\_source" :  
{"id":102,"first\_name":"Jack","last\_name":"Jones","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["jack"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "100",  
"\_score" : null, "\_source" :  
{"id":100,"first\_name":"NAME","last\_name":"asd","machine\_id":58,"email":"test@testme.com","website":"","telephone\_number":"","tags":[]},  
"sort" : ["name"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "111",  
"\_score" : null, "\_source" :  
{"id":111,"first\_name":"NAME","last\_name":"asdasdasd","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["name"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "108",  
"\_score" : null, "\_source" :  
{"id":108,"first\_name":"PEANUT","last\_name":"asdsd","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":[]},  
"sort" : ["peanut"]  
}, {  
"\_index" : "people",  
"\_type" : "person",  
"\_id" : "104",  
"\_score" : null, "\_source" :  
{"id":104,"first\_name":"WillX","last\_name":"SmithX","machine\_id":58,"email":"","website":"","telephone\_number":"","tags":["hello","red"]},  
"sort" : ["willx"]  
} ]  
}  
}%

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Christian\_Th](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Christian\_Th](https://discuss.elastic.co/u/Christian_Th)
#### Post date: [July 24, 2013, 7:51am UTC](https://discuss.elastic.co/t/duplicated-records-returned-using-pagination-after-update/12912/2 "2013-07-24T07:51:30Z")

</div>

This should be correct (changed "from" from 4 to 5):  
{"sort":[{"first\_name":"asc"}],"filter":{"term":{"machine\_id":58}},"size":5,"from":5}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Christian\_Th](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Christian\_Th](https://discuss.elastic.co/u/Christian_Th)
#### Post date: [July 25, 2013, 12:04am UTC](https://discuss.elastic.co/t/duplicated-records-returned-using-pagination-after-update/12912/3 "2013-07-25T00:04:08Z")

</div>

Sorry i think i missed the point before. Is the mapping correct?  
You have the ability to sort without duplicates if you use a mapping like:

......  
"firstname\_sort":  
{  
"type": "string",  
"store": "yes",  
"index": "not\_analyzed"  
}  
......

A duplicated field for sorting and facetting is easy to implement, but  
there are other possibilities.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [July 6, 2017, 2:24am UTC](https://discuss.elastic.co/t/duplicated-records-returned-using-pagination-after-update/12912/4 "2017-07-06T02:24:40Z")

</div>


