Skip to main content

Endpoint

POST /multi-search
Executes multiple search queries across different collections in a single request. This is more efficient than making separate search requests and ensures consistency across results.

Request Body

The request body should contain an object with a searches array.
searches
array
required
Array of search objects, each representing an individual search query

Response

results
array
Array of search results, one for each search in the request

Example Request

Search Across Multiple Collections

{
  "searches": [
    {
      "collection": "transactions",
      "q": "*",
      "filter_by": "status:completed && currency:USD",
      "sort_by": "created_at:desc",
      "per_page": 10
    },
    {
      "collection": "balances",
      "q": "*",
      "filter_by": "currency:USD",
      "sort_by": "balance:desc",
      "per_page": 5
    },
    {
      "collection": "identities",
      "q": "john",
      "query_by": "first_name,last_name,email_address",
      "per_page": 10
    }
  ]
}

Dashboard Overview Query

{
  "searches": [
    {
      "collection": "transactions",
      "q": "*",
      "filter_by": "created_at:>1709467200",
      "facet_by": "status,currency",
      "per_page": 1
    },
    {
      "collection": "balances",
      "q": "*",
      "facet_by": "currency",
      "per_page": 1
    },
    {
      "collection": "reconciliations",
      "q": "*",
      "filter_by": "status:in_progress",
      "per_page": 5
    }
  ]
}

Example Response

{
  "results": [
    {
      "found": 142,
      "hits": [
        {
          "document": {
            "transaction_id": "txn_123abc",
            "amount": 100.50,
            "currency": "USD",
            "status": "completed",
            "created_at": 1709553600
          }
        }
      ],
      "page": 1,
      "out_of": 15
    },
    {
      "found": 89,
      "hits": [
        {
          "document": {
            "balance_id": "bln_456def",
            "balance": "10000.00",
            "currency": "USD",
            "created_at": 1709467200
          }
        }
      ],
      "page": 1,
      "out_of": 18
    },
    {
      "found": 12,
      "hits": [
        {
          "document": {
            "identity_id": "idt_789ghi",
            "first_name": "John",
            "last_name": "Doe",
            "email_address": "john.doe@example.com"
          }
        }
      ],
      "page": 1,
      "out_of": 2
    }
  ]
}

Use Cases

Dashboard Data Loading

Load multiple widgets’ data in a single request:
{
  "searches": [
    {
      "collection": "transactions",
      "q": "*",
      "filter_by": "created_at:>1709467200",
      "per_page": 5
    },
    {
      "collection": "balances",
      "q": "*",
      "sort_by": "balance:desc",
      "per_page": 5
    }
  ]
}
Fetch related data across collections:
{
  "searches": [
    {
      "collection": "transactions",
      "q": "*",
      "filter_by": "source:bln_123abc",
      "per_page": 20
    },
    {
      "collection": "balances",
      "q": "*",
      "filter_by": "balance_id:bln_123abc",
      "per_page": 1
    }
  ]
}

Aggregated Statistics

Get counts and statistics from multiple collections:
{
  "searches": [
    {
      "collection": "transactions",
      "q": "*",
      "facet_by": "status,currency",
      "per_page": 0
    },
    {
      "collection": "balances",
      "q": "*",
      "facet_by": "currency",
      "per_page": 0
    }
  ]
}

Error Responses

error
string
Error message describing what went wrong

Common Errors

  • 400 Bad Request: Invalid request body or search parameters
  • 500 Internal Server Error: Search service error
  1. Performance: Single HTTP request instead of multiple
  2. Consistency: All searches execute at the same point in time
  3. Efficiency: Reduced network overhead and latency
  4. Simplicity: Easier to manage in client code

Best Practices

  1. Limit searches: Don’t include more than 5-10 searches in a single request
  2. Use appropriate per_page: Smaller values for better performance
  3. Combine with caching: Cache multi-search results for frequently accessed data
  4. Error handling: Each search result is independent; one failure doesn’t affect others

Build docs developers (and LLMs) love