Search

The search API supports full-text search with BM25F scoring, prefix matching, typo tolerance, highlighting, pagination, and many other options. All parameters follow the Typesense v30.1 API.

Basic Search

GET /collections/products/documents/search?q=running shoes&query_by=title,description
X-TYPESENSE-API-KEY: YOUR_API_KEY

Search Parameters

ParameterTypeDescription
qstringSearch query text. Use * to match all documents.
query_bystringComma-separated list of fields to search (required).
query_by_weightsstringComma-separated weights for each query_by field (e.g., 3,1,1).
filter_bystringFilter expression. See Filtering.
sort_bystringSort specification. See Sorting.
facet_bystringComma-separated fields for facet counts. See Faceting.
group_bystringGroup results by field. See Grouping.
group_limitintMaximum results per group (default: 3).
per_pageintResults per page (default: 10, max: 250).
pageintPage number (default: 1).

Text Search Options

ParameterTypeDefaultDescription
text_match_typestringall requires all query tokens to match. any matches any token.
prefixbooltrueEnable prefix matching on the last query token.
num_typosint2Maximum edit distance for typo correction (0, 1, or 2).
typo_tokens_thresholdintOnly attempt typo correction if fewer than this many results found.

Highlighting

ParameterTypeDefaultDescription
highlight_fieldsstringComma-separated fields to highlight (defaults to query_by fields).
highlight_start_tagstring<mark>Opening tag for highlight matches.
highlight_end_tagstring</mark>Closing tag for highlight matches.
highlight_affix_num_tokensint4Number of tokens to include around each highlight match.

Advanced Options

ParameterTypeDescription
vector_querystringVector search query. See Vector Search.
presetstringPreset ID to merge into the query. See Presets.
stopwordsstringStopword set ID to apply. See Stopwords.
synonym_setsstringComma-separated synonym set IDs. See Synonyms.
pinned_hitsstringDocument IDs to pin to the top of results (e.g., id1:1,id2:2).
hidden_hitsstringDocument IDs to exclude from results (e.g., id1,id2).
limit_hitsintMaximum number of hits to evaluate.
facet_querystringFilter facet values by prefix (e.g., category:Foot).
max_facet_valuesint10Maximum facet values to return per field.
group_missing_valuesbooltrueInclude documents with missing group_by field values.

Response Format

{
  "found": 2,
  "out_of": 1000,
  "page": 1,
  "search_time_ms": 1,
  "hits": [
    {
      "document": {
        "id": "1",
        "title": "Running Shoes",
        "price": 89.99
      },
      "highlights": [
        {
          "field": "title",
          "snippet": "<mark>Running</mark> <mark>Shoes</mark>",
          "matched_tokens": ["Running", "Shoes"]
        }
      ],
      "text_match": 578730123365711872
    }
  ],
  "facet_counts": [],
  "request_params": {"q": "running shoes", "query_by": "title"}
}

Multi-Search

Execute multiple search queries in a single request:

POST /multi_search
Content-Type: application/json
X-TYPESENSE-API-KEY: YOUR_API_KEY

{
  "searches": [
    {"collection": "products", "q": "shoes", "query_by": "title"},
    {"collection": "products", "q": "boots", "query_by": "title"}
  ]
}

The response contains an array of search results, one per query.

Text Scoring

Torque uses BM25F scoring for text relevance. BM25F is a multi-field extension of BM25 that considers term frequency, inverse document frequency, document length, and per-field weights. The query_by_weights parameter controls how much each field contributes to the final score.

Prefix Search

When prefix is enabled (default), the last token in the query is treated as a prefix. This enables type-ahead suggestions as users type. Prefix matching uses an FST (Finite State Transducer) index for fast lookups.

Typo Tolerance

Torque uses SymSpell for typo correction. When a query token doesn’t match any indexed terms, Torque checks for corrections within the configured edit distance (num_typos, default 2). This handles common misspellings automatically.