kuzzleio / sdk-javascript

Kuzzle Javascript SDK. High level library including multi-protocol support, offline resiliency, realtime data and more
http://docs.kuzzle.io/sdk/js/7
Apache License 2.0
39 stars 15 forks source link

Pagination of search results using scroll using HTTP #564

Closed AndreasFroelich closed 1 year ago

AndreasFroelich commented 3 years ago

Expected Behavior

When using a search with scroll options ".next()" on the searchResult should return the next results or null.

Current Behavior

Error: The index "_scroll" does not exist.'

Possible Solution

I did some digging and added some logs and think i narrowed down the error: For the search API there are POST and GET options. The sdk uses POST by default. Then when using .next() on the search result, it DOES NOT check for the HTTP Method again in the internal publicAPI spec. It uses POST again, which is not supported by the HTTP scroll API, instead of choosing "GET". Therefore Kuzzle thinks another API was called.

Steps to Reproduce

const res = kuzzle.document.search(index,collection, { query : { match_all: {}}}, { scroll: '10s' })
const nextRes = res.next()

What works:

const res = kuzzle.document.search(index,collection, { query : { match_all: {}}}, { scroll: '10s' , verb: 'GET'})
const nextRes = res.next()

Context (Environment)

Kuzzle version: 2.3.3 Node.js version: 12.16.3 SDK version: 7.4.3

AndreasFroelich commented 3 years ago

Any news on this one? @Aschen Have you had time to look into this one? Maybe i would be able to help you with that one. But adding an additional layer of HTTP method check is maybe quite a significant change.

Aschen commented 3 years ago

Hi @AndreasFroelich , Thanks for remembering me that one :sweat_smile: I just submitted a PR