# Paging on 0.90

**URL:** <https://discuss.elastic.co/t/paging-on-0-90/12041>\
**Category:** Elasticsearch\
**Created:** [May 20, 2013, 5:19pm UTC](https://discuss.elastic.co/t/paging-on-0-90/12041 "2013-05-20T17:19:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Gaeremynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simon_gaeremynck/32/2142_2.png) [@Simon\_Gaeremynck](https://discuss.elastic.co/u/Simon_Gaeremynck)\
**Post date:** [May 20, 2013, 5:19pm UTC](https://discuss.elastic.co/t/paging-on-0-90/12041/1 "2013-05-20T17:19:09Z")

</div>

Hello,

I'm seeing the following paging issue on 0.90 that we weren't seeing on  
0.20.6

I have a query with `size` set to 2 and `from` set to 0 that returns the  
documents: [docA, docB]  
When I change the `size` to 1 the result set is [docB]  
When I query with {size: 1, from: 1} I get [docB] again.  
I would expect that {size: 1, from: 0} would return [docA] ?

Both docA and docB have a \_score of 1. The query orders descending on  
\_score first and then sorts ascending on a document field (string). The  
sort field of document A should come before the sort field of document B.

Some details:

- Number of shards: 1
- Number of hits for the query: 2 (the 2 documents are the only hits)
- There is no indexing going on in the background
- Total size of the index: ~2000 documents

The query:  
{  
"query": {  
"filtered": {  
"query": {  
"query\_string": {  
"fields": ["q\_high^2.0", "q\_low^0.75"],  
"query": "\*"  
}  
},  
"filter": {  
"and": [  
{ "term": { "\_type": "resource" } },  
{ "term": { "resourceType": "group" } },  
{ "ids": { "values": [ "g:camtest:groupChild-PTmmhkau0kf",  
"g:camtest:groupParent-TP9mWsIp1k5" ] } }  
]  
}  
}  
},  
"from": 0,  
"size": 2,  
"sort": [  
{ "\_score": { "order": "desc" } },  
{ "sortField": { "order": "asc" } }  
],  
"min\_score": 0.2,  
"explain": true  
}

Kind regards,

Simon

--  
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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [May 20, 2013, 8:19pm UTC](https://discuss.elastic.co/t/paging-on-0-90/12041/2 "2013-05-20T20:19:39Z")

</div>

hey,

I assume this is related  
to [BytesRefOrdValComparator ignores highest value in a segment during binarySearch · Issue #2991 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2991)  
which is essentially a sorting bug. Would you have the spare cycles to try  
if the latest master fixes this problem (or maybe try branch 0.90)

simon

On Monday, May 20, 2013 7:19:09 PM UTC+2, Simon Gaeremynck wrote:

> Hello,
> 
> I'm seeing the following paging issue on 0.90 that we weren't seeing on  
> 0.20.6
> 
> I have a query with `size` set to 2 and `from` set to 0 that returns the  
> documents: [docA, docB]  
> When I change the `size` to 1 the result set is [docB]  
> When I query with {size: 1, from: 1} I get [docB] again.  
> I would expect that {size: 1, from: 0} would return [docA] ?
> 
> Both docA and docB have a \_score of 1. The query orders descending on  
> \_score first and then sorts ascending on a document field (string). The  
> sort field of document A should come before the sort field of document B.
> 
> Some details:
> 
> - Number of shards: 1
> - Number of hits for the query: 2 (the 2 documents are the only hits)
> - There is no indexing going on in the background
> - Total size of the index: ~2000 documents
> 
> The query:  
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "query\_string": {  
> "fields": ["q\_high^2.0", "q\_low^0.75"],  
> "query": "\*"  
> }  
> },  
> "filter": {  
> "and": [  
> { "term": { "\_type": "resource" } },  
> { "term": { "resourceType": "group" } },  
> { "ids": { "values": [ "g:camtest:groupChild-PTmmhkau0kf",  
> "g:camtest:groupParent-TP9mWsIp1k5" ] } }  
> ]  
> }  
> }  
> },  
> "from": 0,  
> "size": 2,  
> "sort": [  
> { "\_score": { "order": "desc" } },  
> { "sortField": { "order": "asc" } }  
> ],  
> "min\_score": 0.2,  
> "explain": true  
> }
> 
> Kind regards,
> 
> Simon

--  
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:** ![Karel\_Minarik\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karel_minarik_2/32/1078_2.png) [@Karel\_Minarik\_2](https://discuss.elastic.co/u/Karel_Minarik_2)\
**Post date:** [May 21, 2013, 7:08am UTC](https://discuss.elastic.co/t/paging-on-0-90/12041/3 "2013-05-21T07:08:11Z")

</div>

Just a note that Tire, the Ruby client, has quite extensive integration  
test suite for  
pagination: [https://github.com/karmi/tire/blob/master/test/integration/active\_record\_searchable\_test.rb#L191](https://github.com/karmi/tire/blob/master/test/integration/active_record_searchable_test.rb#L191),  
which is passing even on 0.90, so this might be highly specific to some  
conditions.

Karel

On Monday, May 20, 2013 10:19:39 PM UTC+2, simonw wrote:

> hey,
> 
> I assume this is related to  
> [BytesRefOrdValComparator ignores highest value in a segment during binarySearch · Issue #2991 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2991)  
> which is essentially a sorting bug. Would you have the spare cycles to try  
> if the latest master fixes this problem (or maybe try branch 0.90)
> 
> simon
> 
> On Monday, May 20, 2013 7:19:09 PM UTC+2, Simon Gaeremynck wrote:
> 
> > Hello,
> > 
> > I'm seeing the following paging issue on 0.90 that we weren't seeing on  
> > 0.20.6
> > 
> > I have a query with `size` set to 2 and `from` set to 0 that returns the  
> > documents: [docA, docB]  
> > When I change the `size` to 1 the result set is [docB]  
> > When I query with {size: 1, from: 1} I get [docB] again.  
> > I would expect that {size: 1, from: 0} would return [docA] ?
> > 
> > Both docA and docB have a \_score of 1. The query orders descending on  
> > \_score first and then sorts ascending on a document field (string). The  
> > sort field of document A should come before the sort field of document B.
> > 
> > Some details:
> > 
> > - Number of shards: 1
> > - Number of hits for the query: 2 (the 2 documents are the only hits)
> > - There is no indexing going on in the background
> > - Total size of the index: ~2000 documents
> > 
> > The query:  
> > {  
> > "query": {  
> > "filtered": {  
> > "query": {  
> > "query\_string": {  
> > "fields": ["q\_high^2.0", "q\_low^0.75"],  
> > "query": "\*"  
> > }  
> > },  
> > "filter": {  
> > "and": [  
> > { "term": { "\_type": "resource" } },  
> > { "term": { "resourceType": "group" } },  
> > { "ids": { "values": [ "g:camtest:groupChild-PTmmhkau0kf",  
> > "g:camtest:groupParent-TP9mWsIp1k5" ] } }  
> > ]  
> > }  
> > }  
> > },  
> > "from": 0,  
> > "size": 2,  
> > "sort": [  
> > { "\_score": { "order": "desc" } },  
> > { "sortField": { "order": "asc" } }  
> > ],  
> > "min\_score": 0.2,  
> > "explain": true  
> > }
> > 
> > Kind regards,
> > 
> > Simon

--  
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:** ![Simon\_Gaeremynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simon_gaeremynck/32/2142_2.png) [@Simon\_Gaeremynck](https://discuss.elastic.co/u/Simon_Gaeremynck)\
**Post date:** [May 21, 2013, 7:39am UTC](https://discuss.elastic.co/t/paging-on-0-90/12041/4 "2013-05-21T07:39:20Z")

</div>

Hi Simon,

Just verified that master (e0825686f323bcb9bb0348ce61068e4af1763316) fixes the issue we're seeing.

Good stuff 🙂

Simon

On 20 May 2013, at 21:19, simonw [simon.willnauer@elasticsearch.com](mailto:simon.willnauer@elasticsearch.com) wrote:

> hey,
> 
> I assume this is related to [BytesRefOrdValComparator ignores highest value in a segment during binarySearch · Issue #2991 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2991)  
> which is essentially a sorting bug. Would you have the spare cycles to try if the latest master fixes this problem (or maybe try branch 0.90)
> 
> simon
> 
> On Monday, May 20, 2013 7:19:09 PM UTC+2, Simon Gaeremynck wrote:  
> Hello,
> 
> I'm seeing the following paging issue on 0.90 that we weren't seeing on 0.20.6
> 
> I have a query with `size` set to 2 and `from` set to 0 that returns the documents: [docA, docB]  
> When I change the `size` to 1 the result set is [docB]  
> When I query with {size: 1, from: 1} I get [docB] again.  
> I would expect that {size: 1, from: 0} would return [docA] ?
> 
> Both docA and docB have a \_score of 1. The query orders descending on \_score first and then sorts ascending on a document field (string). The sort field of document A should come before the sort field of document B.
> 
> Some details:
> 
> - Number of shards: 1
> - Number of hits for the query: 2 (the 2 documents are the only hits)
> - There is no indexing going on in the background
> - Total size of the index: ~2000 documents
> 
> The query:  
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "query\_string": {  
> "fields": ["q\_high^2.0", "q\_low^0.75"],  
> "query": "\*"  
> }  
> },  
> "filter": {  
> "and": [  
> { "term": { "\_type": "resource" } },  
> { "term": { "resourceType": "group" } },  
> { "ids": { "values": ["g:camtest:groupChild-PTmmhkau0kf", "g:camtest:groupParent-TP9mWsIp1k5"] } }  
> ]  
> }  
> }  
> },  
> "from": 0,  
> "size": 2,  
> "sort": [  
> { "\_score": { "order": "desc" } },  
> { "sortField": { "order": "asc" } }  
> ],  
> "min\_score": 0.2,  
> "explain": true  
> }
> 
> Kind regards,
> 
> Simon
> 
> --  
> You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/4jkFmvucijY/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/4jkFmvucijY/unsubscribe?hl=en-US).  
> To unsubscribe from this group and all its topics, 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).

--  
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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [May 21, 2013, 7:52am UTC](https://discuss.elastic.co/t/paging-on-0-90/12041/5 "2013-05-21T07:52:30Z")

</div>

perfect! thanks for verifying!

simon

On Tuesday, May 21, 2013 9:39:20 AM UTC+2, Simon Gaeremynck wrote:

> Hi Simon,
> 
> Just verified that master (e0825686f323bcb9bb0348ce61068e4af1763316) fixes  
> the issue we're seeing.
> 
> Good stuff 🙂
> 
> Simon
> 
> On 20 May 2013, at 21:19, simonw \<[simon.w...@elasticsearch.com](mailto:simon.w...@elasticsearch.com)\<javascript:\>\>  
> wrote:
> 
> > hey,
> > 
> > I assume this is related to  
> > [BytesRefOrdValComparator ignores highest value in a segment during binarySearch · Issue #2991 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2991)  
> > which is essentially a sorting bug. Would you have the spare cycles to  
> > try if the latest master fixes this problem (or maybe try branch 0.90)
> > 
> > simon
> > 
> > On Monday, May 20, 2013 7:19:09 PM UTC+2, Simon Gaeremynck wrote:  
> > Hello,
> > 
> > I'm seeing the following paging issue on 0.90 that we weren't seeing on  
> > 0.20.6
> > 
> > I have a query with `size` set to 2 and `from` set to 0 that returns the  
> > documents: [docA, docB]  
> > When I change the `size` to 1 the result set is [docB]  
> > When I query with {size: 1, from: 1} I get [docB] again.  
> > I would expect that {size: 1, from: 0} would return [docA] ?
> > 
> > Both docA and docB have a \_score of 1. The query orders descending on  
> > \_score first and then sorts ascending on a document field (string). The  
> > sort field of document A should come before the sort field of document B.
> > 
> > Some details:
> > 
> > - Number of shards: 1
> > - Number of hits for the query: 2 (the 2 documents are the only hits)
> > - There is no indexing going on in the background
> > - Total size of the index: ~2000 documents
> > 
> > The query:  
> > {  
> > "query": {  
> > "filtered": {  
> > "query": {  
> > "query\_string": {  
> > "fields": ["q\_high^2.0", "q\_low^0.75"],  
> > "query": "\*"  
> > }  
> > },  
> > "filter": {  
> > "and": [  
> > { "term": { "\_type": "resource" } },  
> > { "term": { "resourceType": "group" } },  
> > { "ids": { "values": [ "g:camtest:groupChild-PTmmhkau0kf",  
> > "g:camtest:groupParent-TP9mWsIp1k5" ] } }  
> > ]  
> > }  
> > }  
> > },  
> > "from": 0,  
> > "size": 2,  
> > "sort": [  
> > { "\_score": { "order": "desc" } },  
> > { "sortField": { "order": "asc" } }  
> > ],  
> > "min\_score": 0.2,  
> > "explain": true  
> > }
> > 
> > Kind regards,
> > 
> > Simon
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/4jkFmvucijY/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/4jkFmvucijY/unsubscribe?hl=en-US).
> 
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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:35am UTC](https://discuss.elastic.co/t/paging-on-0-90/12041/6 "2017-07-06T02:35:35Z")

</div>


