Skip to main content
Version: 2.0

Batch Multiple Queries

Some applications may be designed to be powered by different queries in different parts of the UI. In order to decrease the number of network round trips (and thereby the net latency), you may want to batch those multiple queries with a single API call.

Query Array in a Request

This pattern can be done in Vectara by sending an array of queries in a single request, as in:

{
"query": [
{
... Query 1 ...
},
{
... Query 2 ...
},
...
]
}
info

When using batched queries, each query within the query array counts as a separate query for billing purposes.

Batched Query Responses

When you query Vectara, you get back an array of results. This array is to assist in using batched queries.

{
"responseSet": [
{
... Response 1 ...
},
{
... Response 2 ...
},
...
]
}

Each response object within the responseSet array is directly associated with the query in the same position as the response. e.g. in this example case, the block in Response 1 will be the results for Query 1. Therefore, it's important you keep track of the order of your queries in order to interpret the responses.