Skip to content

Suggesting Terms

Auth required: Authorization: <main_api_key> or Authorization: <search_api_key> header.

The suggest endpoint returns indexed terms that match a given prefix.

Word-Level Matching

Suggest operates at the individual word level. When you pass a multi-word query like "hello wo", only the last word ("wo") is used as the prefix for matching against the FST. The FST stores single lemmatized tokens from your documents (e.g. hello, world, application), so suggestions are always whole words, never phrases.

Multi-word query examples:

InputPrefix usedMatches
applapplapple, application, …
hello appappapple, application, …
search wowoword, world, wonder, …

Example

js
const { results } = await client.suggest("posts", {
  q: "hello app",
  take: 5,
});
// results → ["apple", "application", "appliance"]
js
const params = new URLSearchParams({
  q: "hello app",
  take: "5",
});
const res = await fetch(
  `http://localhost:3000/collections/posts/suggest?${params}`,
  { headers: { Authorization: "SecretApiKey" } },
);
const { results, take } = await res.json();
sh
curl "http://localhost:3000/collections/posts/suggest?q=hello+app&take=5" \
  -H "Authorization: SecretApiKey"

# Response: 200 OK
# {
#   "results": ["apple", "application", "appliance"],
#   "take": 5
# }

Endpoint Definition

FieldValue
MethodGET
Path/collections/{collection}/suggest

Query Parameters

ParamTypeDefaultDescription
qstringPrefix to match against indexed terms (only the last word is used)
takeinteger10Max suggestions (clamped 1 – 100)

Response Body

FieldTypeDescription
resultsarray of stringMatching indexed terms (single words, not phrases)
takeintegerNumber of suggestions returned

Response: 200 OK

Notes

  • The FST is a best-effort vocabulary index. Terms are batched during index queue processing and consolidated to disk periodically (configurable via fst_consolidate_interval_secs).
  • Terms from deleted documents may remain in the FST until the next full consolidation; this is an eventual-consistency trade-off.
  • Matching is prefix-based only — partial infix or substring matching is not supported.