Documents

Autocomplete

Get suggestions as the user types from any text database. There's nothing to set up. Vecstore learns words and phrases from the documents already in the database.

POST/databases/{id}/autocomplete

Note: autocomplete works with text databases only. It isn't available for image databases.

Request

Replace {id} in the path with your database ID and send what the user has typed so far.

Example request
{
  "query": "wireless hea",
  "limit": 5
}

Query ·required

query string
The text typed so far

Options ·optional

limit integer
Number of suggestions to return, from 1 to 10. Defaults to 5

Response

Returns suggestions, best first.

Example response
{
  "suggestions": [
    { "text": "wireless headphones" },
    { "text": "wireless headset" }
  ],
  "status": "ready",
  "search_time": "0.42ms"
}
suggestions array
Suggested completions. Each has a text field with the suggested query
status string
ready, or building while the index is being created
search_time string
Time spent finding suggestions

How Suggestions Work

TypedSuggestsWhy
wireless hea wireless headphones Completes the current word, using the word before it for context
wireless wireless headphones After a space, suggests the next word
headphnes headphones Allows one wrong letter in words of 4 to 20 characters

Suggestions are ranked by how often they appear in your documents, and come from your content, not from what users have searched for. To show results when a user picks one, send it to Search Documents.

Index Building

The first time you call autocomplete on a database, Vecstore builds a word and phrase index from its documents. Until it's ready, the response has status: "building" and no suggestions.

While building
{
  "suggestions": [],
  "status": "building",
  "search_time": "0.05ms"
}

After that, the index refreshes on its own as you add or delete documents. New documents show up in suggestions after the next refresh, not instantly.

Credits

Autocomplete costs 1 credit per 25 requests. Suggestions are served from memory without an embedding call, so you can call it on every keystroke. The dashboard's Autocomplete tab is billed the same way.