Skip to main content
A comparison of the AI strategies of 60 countries is 60 searches that differ in 2 things: the country, and the language of the question. search_batch runs up to 20 searches in one call, so the comparison is 3 calls. Each search gets its own question, and the rules for ranking and filtering are written once.

Send the questions

Put each question in items, and the fields that all of them share at the top. This request asks 3 countries the same question, each in 4 wordings, in English and in the country’s own language.
Replace IDEMPOTENCY_KEY with a value of your own that is new for each batch. A batch must have this key, so that a batch sent twice is not run and charged twice. The SDKs make the key for you.

Read the tally first

The response starts with counts, and then has one result for each item, in the order you sent them. This response is cut to the tally and to the outcome of each search.
200 OK
Each result is a whole search, with its results, its receipt, and an id of its own, so get_search reads it again later. An item that could not run has a problem in place of a search and is counted as skipped. One item never stops the others.

Know which fields belong to an item

An item has the question and what belongs to it. Every other field of a search is set at the top and applies to all items: the datasources, the filters, the ranking, the sizes. A field in the wrong place is refused, and the problem says where it belongs.

Read the first result of each search in the same call

contents at the top applies to every search of the batch. Set top to 1, and put your questions in highlights and your fields in json_schema. One call then returns, for each of 20 countries, the first official source, the passages that bear on your questions, and a filled row. For those fields, see Search and get the evidence in one call.

Plan for the time a batch takes

Each search has its own wait_seconds, counted from its own start. A batch has a time limit of its own, which get_limits returns. An item that was not started by then is skipped, and its problem says after how many seconds to send it again.

Check what a batch of searches costs

A batch costs the sum of its searches. max_cost is the spending limit of the whole call, divided among the items in the order you sent them. An item that the rest of the limit cannot cover is skipped, and its problem names the limit that stopped it.