Esc
ZeroIndex
GuidesAPI referenceSDKsChangelogOverviewBuy ZeroIndex

Multi search

View as MarkdownThe page as plain text

Run several searches in one request, across one index or many, and get every result set back together.

POST/v1/multi-search

Use it for a search page that shows products and articles side by side, or to count facets with and without a filter in one round trip. Works with admin keys and search keys.

Body

queriesobject[]required

Up to 10 searches. Each takes indexUid plus any parameter from Search.

Response

resultsobject[]

One result set per query, in the order you sent them.

Request

curl https://api.zeroindex.test/v1/multi-search \
  -H "Authorization: Bearer $ZEROINDEX_KEY" \
  -d '{
    "queries": [
      { "indexUid": "products", "q": "lamp", "limit": 3 },
      { "indexUid": "articles", "q": "lamp", "limit": 2 }
    ]
  }'
const { results } = await client.multiSearch({
  queries: [
    { indexUid: "products", q: "lamp", limit: 3 },
    { indexUid: "articles", q: "lamp", limit: 2 },
  ],
});
results = client.multi_search([
    {"indexUid": "products", "q": "lamp", "limit": 3},
    {"indexUid": "articles", "q": "lamp", "limit": 2},
])

Response

200
{
  "results": [
    {
      "indexUid": "products",
      "hits": [{ "id": 1043, "name": "Desk lamp" }],
      "estimatedTotalHits": 9,
      "processingTimeMs": 3
    },
    {
      "indexUid": "articles",
      "hits": [{ "slug": "lighting-a-small-office", "title": "Lighting a small office" }],
      "estimatedTotalHits": 2,
      "processingTimeMs": 2
    }
  ]
}