Databases
Typesense Search Engine Management in VS Code
Overview
Section titled “Overview”Typesense is an open-source search engine that stores JSON documents in collections and returns typo-tolerant results as you type. You work with it over an HTTP API, and each collection has a schema that lists its fields and their types.
Connecting
Section titled “Connecting”To connect to Typesense in DBCode:
- Open the DBCode Extension: Launch Visual Studio Code and open the DBCode extension.
- Add a New Connection: Click on the “Add Connection” icon.
- Complete connection form: Select Typesense as the database type and enter:
- Host and port (default
8108) - SSL/TLS settings (if required)
- An API key: an admin key, or a key with the actions you need. You can also select a Command authentication profile instead of storing the key directly. A key with the
documents:searchandcollections:listactions can browse and search collections, and the admin folders show empty.
- Host and port (default
- Connect: Click save to establish your connection.
- Start Managing Your Data: Browse collections, documents, and the admin folders.
For Typesense Cloud, use your cluster’s host name, port 443, and turn SSL on.
For detailed instructions on connecting, refer to the Connect article.
Typesense Features in DBCode
Section titled “Typesense Features in DBCode”Browsing and editing documents
Section titled “Browsing and editing documents”- Collections as tables: Each collection appears as a table. Open one to page through its documents in the grid.
- Filtering: Filter in the grid with equals, not equal, and starts with. Equals and starts with ignore upper and lower case and punctuation, as Typesense matches text. Starts with matches the start of the whole value, or of any element in a list field. Greater than and less than work on number fields. A filter value can’t contain a backtick (
`), and DBCode tells you when one does. Contains, ends with, and empty-value filters are not available in Typesense, and DBCode tells you so when you apply one. - Sorting: Sort in the grid on sortable fields. Number fields are sortable by default; other fields need
"sort": truein the collection schema. - Editing: Insert, update, and delete documents in the grid. Documents are matched by their
id, which Typesense always stores as a string. Theidcannot be changed afterwards (DBCode refuses the change when you save). - Truncate and drop: Right-click a collection to remove all of its documents with Truncate, or delete the collection with Drop.
Search queries
Section titled “Search queries”The query editor runs JSON search statements. Every key except collection is passed to Typesense as a search parameter:
{ "collection": "products", "q": "shoe", "query_by": "title" }Use "q": "*" to match every document without query_by. If a search sets no limit, DBCode applies your usual row limit. A grouped search (group_by) shows one row per hit, with the hit’s group key in a group_key column. Results in the editor are read-only; to edit documents, open the collection in the grid.
Changing fields
Section titled “Changing fields”A statement with a fields array changes the collection’s schema. Add a field with its name and type, or drop one with "drop": true:
{ "collection": "products", "fields": [{ "name": "rating", "type": "float" }] }{ "collection": "products", "fields": [{ "name": "rating", "drop": true }] }DBCode waits for the change to finish before showing the result. If you stop the query while it waits, the change carries on in Typesense.
Right-click a collection and choose Script > CREATE (DDL) to see its current schema as comments, followed by a fields statement ready for the fields you want to add or drop.
Admin folders
Section titled “Admin folders”Each connection shows these folders next to the collections. Their items are read-only, and Script opens an item’s definition as JSON.
- Aliases, Presets, and Stopwords.
- Keys: API keys, listed by description. Only the first 4 characters of each key are shown.
- Synonym Sets and Curation Sets: on Typesense 30 and later, these are top-level folders. On earlier versions, each collection shows its own Synonyms and Overrides folders instead, when it has any.
Monitoring and read-only connections
Section titled “Monitoring and read-only connections”- Monitoring: See server resources (CPU, memory, and disk), request rates and latency, and any schema changes in progress.
- Read-only connections: Mark a connection read-only to block every write, including document edits and field changes, while still allowing searches and browsing.
By using Typesense with DBCode, you can manage your search collections directly within Visual Studio Code.
For more information about Typesense, check out Typesense.