Search
Multi-search
Run several Typesense searches in one request with the Go 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
Go response (
client.Search.MultiSearch to search more than one collection in a single request.
1
Call the method
client.Search.MultiSearch
multiResp, resp, err := client.Search.MultiSearch(blnkgo.MultiSearchRequest{
Searches: []blnkgo.MultiSearchCollectionParams{
{
Collection: "ledgers",
Q: "Customer ledger",
QueryBy: "name",
PerPage: 5,
},
{
Collection: "balances",
Q: "*",
QueryBy: "currency",
PerPage: 1,
},
},
})
if err != nil {
fmt.Printf("Error running multi-search: %v\n", err)
return
}
fmt.Printf("HTTP status: %d\n", resp.StatusCode)
fmt.Printf("Ledgers found: %d\n", multiResp.Results[0].Found)
| Field | Type | Description |
|---|---|---|
Searches | []blnkgo.MultiSearchCollectionParams | One or more searches. Results come back in the same order. |
Collection | string | Collection to search: ledgers, transactions, balances, or identities. |
Q | string | Search query text. Use * to return all records. |
QueryBy | string | Comma-separated list of fields to search in. |
FilterBy | string | Filter conditions to refine results. |
SortBy | string | Sort order, for example created_at:desc. |
Page | int | Page number, starting at 1. |
PerPage | int | Results per page. Max 250, defaults to 10. |
2
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
}
]
}
]
}
Go response (*blnkgo.MultiSearchResponse)
| Field | Type | Description |
|---|---|---|
Results | []blnkgo.SearchResponse | One result object per search, in Searches order. |
Results[i].Found | int | Number of records matching that search. |
Results[i].OutOf | int | Total records in that collection. |
Results[i].Page | int | Current page number. |
Results[i].SearchTimeMs | int | Time taken to run that search, in milliseconds. |
Results[i].Hits | []blnkgo.SearchHit | Array of results, each with a Document field. |
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