Search
Multi-search
Run several Typesense searches in one request with the Java 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().multiSearch for this operation.
1
Call the method
ApiResponse<JsonNode> response = blnk.search().multiSearch(
MultiSearchParams.create()
.add("ledgers", SearchParams.create().q("Customer ledger").queryBy("name").perPage(5))
.add("balances", SearchParams.create().q("*").queryBy("currency").perPage(1)));
| Field | Type | Description |
|---|---|---|
add(collection, params) | MultiSearchParams | Appends one search. collection is 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 | Number | Page number, starting at 1. |
perPage | Number | Results per page. Max 250, defaults to 10. |
2
Use the search results
Read
response.data().get("results"). Each bucket matches one add() call, in insertion order, 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 | JsonNode | JSON array of result objects, one per add(), in insertion 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 | JsonNode | JSON array of search results. Each element includes 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