Skip to main content
Version: 1.0

Enable Pagination in Search Results

Pagination provides you with customization options for individual preferences or application requirements. Upon query, Vectara returns the first 10 most relevant search results by default. However, there are times when this is not enough and you want to offer your users the ability to paginate through results.

To enable pagination, use the start and num_results parameters under the query.

Example: Set Results to 20 Per Page

To page through where each page has 20 results, you set start to 0 and num_results to 20.

{
"query": [
{
"query": "What is offsides?",
"queryContext": "",
"start": 0,
"numResults": 20,
"contextConfig": {
"charsBefore": 0,
"charsAfter": 0,
"sentencesBefore": 2,
"sentencesAfter": 2,
"startTag": "%START_SNIPPET%",
"endTag": "%END_SNIPPET%"
},
"corpusKey": [

// ...

],
"summary": [

// ...
]
}
]
}

Example: Set Results to Begin on Page 2

Then if your users want to paginate to page 2, you would send start as 20 and num_results to 20, and for each page following, add another 20 to the start.

{
"query": [
{
"query": "What is offsides?",
"queryContext": "",
"start": 20,
"numResults": 20,
"contextConfig": {
"charsBefore": 0,
"charsAfter": 0,
"sentencesBefore": 2,
"sentencesAfter": 2,
"startTag": "%START_SNIPPET%",
"endTag": "%END_SNIPPET%"
},
"corpusKey": [

// ...

],
"summary": [

// ...
]
}
]
}