Class: OpenSearchPaginator

opensearch/paginator.OpenSearchPaginator(url, parameters, optionsopt)

Class to help with paginated results of an OpenSearch service.

Constructor

new OpenSearchPaginator(url, parameters, optionsopt)

Parameters:
Name Type Attributes Description
url OpenSearchUrl The URL to perform all subsequent requests on.
parameters object Search parameters.
options object <optional>
Additional options for the pagination
Properties
Name Type Attributes Default Description
useCache boolean <optional>
true Whether response pages shall be cached.
preferredItemsPerPage int <optional>
The preferred page size. This defaults to the advertised default of the URL.
preferStartIndex boolean <optional>
true Whether the paging shall be done using the `startIndex` parameter (the default) or the `startPage`.
baseOffset int <optional>
0 The base index offset to apply. This option is useful when resuming a consecutive search.
maxUrlLength int <optional>
The maximum URL length. Forwarded to search.
Source:

Methods

fetchAllPages() → {Promise.<Array.<SearchResult>>}

Fetches all pages from the URL. A probing request is sent to determine how many succeeding requests have to be sent.
Source:
Returns:
The async result of all the pages in the search.
Type
Promise.<Array.<SearchResult>>

fetchAllRecords() → {Promise.<SearchResult>}

Convenience method to get the records of all pages in a single result array
Source:
Returns:
The records of all the pages in the search.
Type
Promise.<SearchResult>

fetchFirstRecords(maxCount) → {Promise.<SearchResult>}

Fetches the first X records of a search in a single search result.
Parameters:
Name Type Description
maxCount int The maximum number of records to fetch.
Source:
Returns:
The resulting records as a promise.
Type
Promise.<SearchResult>

fetchPage(pageIndexopt, maxCountopt) → {Promise.<SearchResult>}

Fetch a single page of the result set. Sets the server side items per page, when the result is available.
Parameters:
Name Type Attributes Default Description
pageIndex int <optional>
0 The index of the page to be fetched.
maxCount int <optional>
The maximum count of objects to be retrieved.
Source:
Returns:
The search result.
Type
Promise.<SearchResult>

getActualPageSize() → {int}

Returns the actual page size.
Source:
Returns:
The computed page size.
Type
int

getPageCount() → {int}

Returns the computed number of pages, which is available once the first page was received.
Source:
Returns:
The number of pages.
Type
int

searchFirstRecords(maxCount, preserveOrder) → {module:opensearch/paginator~PagedSearchProgressEmitter}

Fetches the first X records of a search in a single search result. Use this method when the progressive results are wished and not just a final result.
Parameters:
Name Type Default Description
maxCount int The maximum number of records to fetch.
preserveOrder boolean true Whether the results must be returned in the order received from the server, or the originally requested order.
Source:
Returns:
The resulting records as a promise.
Type
module:opensearch/paginator~PagedSearchProgressEmitter