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.

Path Parameters

idstringrequired
The database ID

Request Body

Send what the user has typed so far.

querystringrequired
The text typed so far
limitinteger
Number of suggestions to return, from 1 to 10. Defaults to 5
Example request
{
  "query": "wireless hea",
  "limit": 5
}

Response

suggestionsarray
Suggested completions, best first
statusstring
ready, or building while the index is being created
search_timestring
Time spent finding suggestions

Suggestion object

textstring
The suggested query
Example response
{
  "suggestions": [
    { "text": "wireless headphones" },
    { "text": "wireless headset" }
  ],
  "status": "ready",
  "search_time": "0.42ms"
}

How Suggestions Work

  • It completes the word being typed and uses the word before it for context. wireless hea suggests wireless headphones and wireless headset.
  • After a space, it suggests the next word. wireless suggests wireless headphones.
  • It allows one wrong letter in words of 4 to 20 characters. headphnes still finds headphones.
  • Suggestions are ranked by how often they appear in your documents.
  • Suggestions come from your content, not from what users have searched for.

To show results when a user picks a suggestion, 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.