Search
Multi-search
Run several Typesense searches in one request with the Python SDK.
POST
/
multi-search
Multi-search
curl --request POST \
--url http://localhost:5001/multi-search \
--header 'X-blnk-key: <api-key>'import requests
url = "http://localhost:5001/multi-search"
headers = {"X-blnk-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-blnk-key': '<api-key>'}};
fetch('http://localhost:5001/multi-search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "5001",
CURLOPT_URL => "http://localhost:5001/multi-search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-blnk-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:5001/multi-search"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-blnk-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:5001/multi-search")
.header("X-blnk-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:5001/multi-search")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["X-blnk-key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyUse
blnk.search.multi_search to search more than one collection in a single request.
1
Call the method
blnk.search.multi_search
response = blnk.search.multi_search(
{
"searches": [
{
"collection": "ledgers",
"q": "Customer ledger",
"query_by": "name",
"per_page": 5,
},
{
"collection": "balances",
"q": "*",
"query_by": "currency",
"per_page": 1,
},
]
}
)
| Field | Type | Description |
|---|---|---|
searches | list[dict] | One or more searches. Results come back in the same order. |
searches[].collection | str | Collection to search: ledgers, transactions, balances, or identities. |
searches[].q | str | Search query text. Use * to return all records. |
searches[].query_by | str | Comma-separated list of fields to search in. |
searches[].filter_by | str | Filter conditions to refine results. |
searches[].sort_by | str | Sort order, for example created_at:desc. |
searches[].page | number | Page number, starting at 1. |
searches[].per_page | number | Results per page. Max 250, defaults to 10. |
2
Use the search results
Read
response.data["results"]. Each bucket matches one entry in searches and includes found, hits, and the same fields as a single-collection search.3
Response
200 OK
{
"results": [
{
"found": 1,
"out_of": 12,
"page": 1,
"request_params": {
"collection_name": "ledgers",
"per_page": 5,
"q": "Customer ledger"
},
"search_time_ms": 2,
"facet_counts": [],
"search_cutoff": false,
"hits": [
{
"document": {
"id": "ldg_cd728825-a6e1-4fae-9277-c3235a045ea5",
"ledger_id": "ldg_cd728825-a6e1-4fae-9277-c3235a045ea5",
"name": "Customer ledger",
"created_at": 1758116489
},
"highlights": [],
"text_match": 578730123365711993
}
]
},
{
"found": 4,
"out_of": 40,
"page": 1,
"request_params": {
"collection_name": "balances",
"per_page": 1,
"q": "*"
},
"search_time_ms": 1,
"hits": [
{
"document": {
"id": "bln_93fb50c2-969e-49c2-bb61-ef5ed245516e",
"balance_id": "bln_93fb50c2-969e-49c2-bb61-ef5ed245516e",
"currency": "USD",
"ledger_id": "ldg_cd728825-a6e1-4fae-9277-c3235a045ea5",
"created_at": 1758116489
},
"highlights": [],
"text_match": 578730123365711993
}
]
}
]
}
| Field | Type | Description |
|---|---|---|
results | list[dict] | One result object per search, in searches order. |
results[].found | number | Number of records matching that search. |
results[].out_of | number | Total records in that collection. |
results[].page | number | Current page number. |
results[].search_time_ms | number | Time taken to run that search, in milliseconds. |
results[].hits | list[dict] | Array of results, each with a document and optional highlights and text_match. |
Need help?
We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool. To ask questions or discuss issues, please contact us or join our Discord community.Was this page helpful?
⌘I