# Paging With Completion Suggester

**URL:** https://discuss.elastic.co/t/paging-with-completion-suggester/20358
**Category:** Elasticsearch
**Created:** [October 21, 2014, 9:28am UTC](https://discuss.elastic.co/t/paging-with-completion-suggester/20358 "2014-10-21T09:28:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Delaney](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_delaney/32/1095_2.png) [@Michael\_Delaney](https://discuss.elastic.co/u/Michael_Delaney)
#### Post date: [October 21, 2014, 9:28am UTC](https://discuss.elastic.co/t/paging-with-completion-suggester/20358/1 "2014-10-21T09:28:40Z")

</div>

Hi,

I want to page my completion suggester results.

at present I have a request like the following:

var skip = (pageNumber - 1) \* this.pageSize;

this.client.suggest({  
index: 'books',  
type: 'book',  
body: {  
search\_books : {  
text : term,  
completion : {  
from : skip,  
size : this.pageSize,  
field : "suggested\_book"  
}  
}  
}  
});

But i dont know how to generate a page as it doesnt return a valid Total.

i.e. i need something like:

var total = resp.search\_books.total;  
var pages = Math.max(1, Math.ceil(total/this.pageSize));

Any ideas how best to proceed???

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a43578fe-47e9-4231-bade-908cb07400c1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a43578fe-47e9-4231-bade-908cb07400c1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Michael\_Delaney](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_delaney/32/1095_2.png) [@Michael\_Delaney](https://discuss.elastic.co/u/Michael_Delaney)
#### Post date: [October 21, 2014, 12:19pm UTC](https://discuss.elastic.co/t/paging-with-completion-suggester/20358/2 "2014-10-21T12:19:37Z")

</div>

For now i'm just going to go with \<\<\< Previous Next \>\>\> buttons.

if options.length \>= pagesize then we have more.  
if page \> 1, then we have less.

On Tuesday, 21 October 2014 10:28:40 UTC+1, Michael Delaney wrote:

> Hi,
> 
> I want to page my completion suggester results.
> 
> at present I have a request like the following:
> 
> var skip = (pageNumber - 1) \* this.pageSize;
> 
> this.client.suggest({  
> index: 'books',  
> type: 'book',  
> body: {  
> search\_books : {  
> text : term,  
> completion : {  
> from : skip,  
> size : this.pageSize,  
> field : "suggested\_book"  
> }  
> }  
> }  
> });
> 
> But i dont know how to generate a page as it doesnt return a valid Total.
> 
> i.e. i need something like:
> 
> var total = resp.search\_books.total;  
> var pages = Math.max(1, Math.ceil(total/this.pageSize));
> 
> Any ideas how best to proceed???

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9ac230fb-cf2e-489d-b25c-e80fd008e5a6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9ac230fb-cf2e-489d-b25c-e80fd008e5a6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Michael\_Delaney](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_delaney/32/1095_2.png) [@Michael\_Delaney](https://discuss.elastic.co/u/Michael_Delaney)
#### Post date: [October 21, 2014, 1:16pm UTC](https://discuss.elastic.co/t/paging-with-completion-suggester/20358/3 "2014-10-21T13:16:46Z")

</div>

so "suggest" does not support "from" ??

i guess this feature is not meant to be used with any reasonably sized data  
set??

On Tuesday, 21 October 2014 13:19:37 UTC+1, Michael Delaney wrote:

> For now i'm just going to go with \<\<\< Previous Next \>\>\> buttons.
> 
> if options.length \>= pagesize then we have more.  
> if page \> 1, then we have less.
> 
> On Tuesday, 21 October 2014 10:28:40 UTC+1, Michael Delaney wrote:
> 
> > Hi,
> > 
> > I want to page my completion suggester results.
> > 
> > at present I have a request like the following:
> > 
> > var skip = (pageNumber - 1) \* this.pageSize;
> > 
> > this.client.suggest({  
> > index: 'books',  
> > type: 'book',  
> > body: {  
> > search\_books : {  
> > text : term,  
> > completion : {  
> > from : skip,  
> > size : this.pageSize,  
> > field : "suggested\_book"  
> > }  
> > }  
> > }  
> > });
> > 
> > But i dont know how to generate a page as it doesnt return a valid Total.
> > 
> > i.e. i need something like:
> > 
> > var total = resp.search\_books.total;  
> > var pages = Math.max(1, Math.ceil(total/this.pageSize));
> > 
> > Any ideas how best to proceed???

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1dc9d938-6ecd-4f7b-96f3-bdbe099d431a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1dc9d938-6ecd-4f7b-96f3-bdbe099d431a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Michael\_Delaney](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_delaney/32/1095_2.png) [@Michael\_Delaney](https://discuss.elastic.co/u/Michael_Delaney)
#### Post date: [October 21, 2014, 1:17pm UTC](https://discuss.elastic.co/t/paging-with-completion-suggester/20358/4 "2014-10-21T13:17:12Z")

</div>

so "suggest" does not support "from" ??

i guess this feature is not meant to be used with any reasonably sized data  
set??

On Tuesday, 21 October 2014 10:28:40 UTC+1, Michael Delaney wrote:

> Hi,
> 
> I want to page my completion suggester results.
> 
> at present I have a request like the following:
> 
> var skip = (pageNumber - 1) \* this.pageSize;
> 
> this.client.suggest({  
> index: 'books',  
> type: 'book',  
> body: {  
> search\_books : {  
> text : term,  
> completion : {  
> from : skip,  
> size : this.pageSize,  
> field : "suggested\_book"  
> }  
> }  
> }  
> });
> 
> But i dont know how to generate a page as it doesnt return a valid Total.
> 
> i.e. i need something like:
> 
> var total = resp.search\_books.total;  
> var pages = Math.max(1, Math.ceil(total/this.pageSize));
> 
> Any ideas how best to proceed???

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b0663dcd-5f22-4d9d-ade0-952d66e18dab%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b0663dcd-5f22-4d9d-ade0-952d66e18dab%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:54am UTC](https://discuss.elastic.co/t/paging-with-completion-suggester/20358/5 "2017-07-06T00:54:43Z")

</div>


