# Multiple terms query match with pagination

**URL:** <https://discuss.elastic.co/t/multiple-terms-query-match-with-pagination/179514>\
**Category:** Elasticsearch\
**Created:** [May 3, 2019, 10:23am UTC](https://discuss.elastic.co/t/multiple-terms-query-match-with-pagination/179514 "2019-05-03T10:23:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepak\_Jaganath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepak_jaganath/32/35304_2.png) [@Deepak\_Jaganath](https://discuss.elastic.co/u/Deepak_Jaganath)\
**Post date:** [May 3, 2019, 10:23am UTC](https://discuss.elastic.co/t/multiple-terms-query-match-with-pagination/179514/1 "2019-05-03T10:23:12Z")

</div>

I am using elastic search in my node js projec, version of elastic search is 6.2 .I have used NPM package mongosastic for searching the index.During a multiple terms query search the pagination is not working.The same result is returned after each hit of pagination.The query is supposed to sort by date of the field being created.  
**Query**  
Paperupload.esSearch({  
from:from,  
size:size,  
query:{  
bool:{  
"must": {  
"bool" : { "should": [{terms : {"userId.\_id": followersDetail}}] }  
},  
"must": {  
"bool" : { "should": [{terms : {"topics.topic\_name": topi}}] }  
},  
"must\_not": {  
"bool" : { "should": [{terms : {"\_id": userPapersId}}] }  
}  
}  
},  
sort:{  
"createdAt":{  
"order" : "desc"  
}  
}  
},  
function(err, results) {  
con  
})

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 3, 2019, 12:54pm UTC](https://discuss.elastic.co/t/multiple-terms-query-match-with-pagination/179514/2 "2019-05-03T12:54:40Z")

</div>

Are you sure the `from` and `size` parameters are being set correctly?  
Also, recognise that the search API does not preserve a single-point-in-time view between requests so any updates between requests may push something that was on page1 of search request 1 onto page 2 of search request 2, particularly if sorting by date.

---

<div class="post-metadata">

**Author:** ![Deepak\_Jaganath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepak_jaganath/32/35304_2.png) [@Deepak\_Jaganath](https://discuss.elastic.co/u/Deepak_Jaganath)\
**Post date:** [May 3, 2019, 1:15pm UTC](https://discuss.elastic.co/t/multiple-terms-query-match-with-pagination/179514/3 "2019-05-03T13:15:49Z")

</div>

my first hit FROM is 0 and size is 20.In Next hit from is 1 and size is 20

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 3, 2019, 1:18pm UTC](https://discuss.elastic.co/t/multiple-terms-query-match-with-pagination/179514/4 "2019-05-03T13:18:10Z")

</div>

from is the document number not a page number.

> [@Deepak\_Jaganath](#):
>
> Next hit from is 1 and size is 20

This is asking for everything after the first doc

---

<div class="post-metadata">

**Author:** ![Deepak\_Jaganath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepak_jaganath/32/35304_2.png) [@Deepak\_Jaganath](https://discuss.elastic.co/u/Deepak_Jaganath)\
**Post date:** [May 3, 2019, 1:19pm UTC](https://discuss.elastic.co/t/multiple-terms-query-match-with-pagination/179514/5 "2019-05-03T13:19:16Z")

</div>

So my next hit should be from is 20 and size is 20

---

<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:** [May 31, 2019, 1:19pm UTC](https://discuss.elastic.co/t/multiple-terms-query-match-with-pagination/179514/6 "2019-05-31T13:19:21Z")

</div>

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