Typesense
Import rows into Typesense collections, search and find as rows, update or delete by filter and export. Typical uses: give an application fast search, search a catalogue.
typesense pingtypesense infotypesense collection_createtypesense collection_createtypesense collectionstypesense collectionstypesense inserttypesense inserttypesense collection_infotypesense puttypesense puttypesense searchtypesense searchtypesense searchtypesense findtypesense findtypesense counttypesense counttypesense updatetypesense updatetypesense gettypesense exporttypesense exporttypesense deletetypesense delete_wheretypesense delete_wheretypesense requesttypesense requesttypesense collection_drop

typesense ping <config>


Description

    Test the server: {ok}

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
admin
typesense ping "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}"
mentdb
{"ok": true}

typesense info <config>


Description

    The server: {version, state, collections (their number)}

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
admin
typesense info "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}"
mentdb
{"version": "30.2", "state": 1, "collections": 0}

typesense collection_create <config> <name>


Description

    Create a collection with automatic fields (.* auto). Returns {created, fields}

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    name:   The collection name - String - required
admin
typesense collection_create "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "logs"
mentdb
{"created": "logs", "fields": 1}

typesense collection_create <config> <name> <options_json>


Description

    Create a collection with options: the rest of the schema (fields, default_sorting_field, enable_nested_fields, token_separators...)

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    name:   The collection name - String - required
    options_json:   The options - String - required
admin
typesense collection_create "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "{\"fields\": [{\"name\": \"title\", \"type\": \"string\"}, {\"name\": \"author\", \"type\": \"string\", \"facet\": true}, {\"name\": \"year\", \"type\": \"int32\"}, {\"name\": \"price\", \"type\": \"float\"}], \"default_sorting_field\": \"year\"}"
mentdb
{"created": "books", "fields": 4}

typesense collections <config>


Description

    The names of the collections

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
admin
typesense collections "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}"
mentdb
["books", "logs"]

typesense collections <config> <options_json>


Description

    The collections with options: details (true: rows {name, num_documents, fields, default_sorting_field, created_at})

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    options_json:   The options - String - required
admin
typesense collections "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "{\"details\": true}"
mentdb
[{"name": "books", "num_documents": 0, "fields": 4, "default_sorting_field": "year", "created_at": 1794914647}, {"name": "logs", "num_documents": 0, "fields": 1, "default_sorting_field": "", "created_at": 1794914647}]

typesense insert <config> <collection> <rows_json>


Description

    Insert MQL rows (JSONL import, action upsert), by batches of 10000. Returns {inserted, error_count, errors}: the errors per row (100 detailed) do not stop the others; a row without a result line counts as an error; a failed batch stops the call with the number of rows already written

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    rows_json:   The MQL rows: a JSON array of objects - String - required
admin
typesense insert "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "[{\"id\": 1, \"title\": \"Les Misérables\", \"author\": \"Hugo\", \"year\": 1862, \"price\": 12.5}, {\"id\": 2, \"title\": \"Notre-Dame de Paris\", \"author\": \"Hugo\", \"year\": 1831, \"price\": 9.9}, {\"id\": 3, \"title\": \"Madame Bovary\", \"author\": \"Flaubert\", \"year\": 1857, \"price\": 7.2}, {\"id\": 4, \"title\": \"Germinal\", \"author\": \"Zola\", \"year\": 1885, \"price\": 8.4}, {\"id\": 5, \"title\": \"Nana\", \"author\": \"Zola\", \"year\": \"unknown\", \"price\": 6}]"
mentdb
{"inserted": 4, "error_count": 1, "errors": [{"row": 5, "error": "Field `year` must be an int32.", "code": 400}]}

typesense insert <config> <collection> <rows_json> <options_json>


Description

    Insert with options: action (create, upsert, update, emplace), id_field, batch_size (10000), dirty_values (coerce_or_reject, coerce_or_drop, drop, reject)

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    rows_json:   The MQL rows: a JSON array of objects - String - required
    options_json:   The options - String - required
admin
typesense insert "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "logs" "[{\"n\": 1, \"level\": \"info\"}, {\"n\": 2, \"level\": \"error\"}]" "{\"id_field\": \"n\", \"action\": \"create\"}"
mentdb
{"inserted": 2, "error_count": 0, "errors": []}

typesense collection_info <config> <collection>


Description

    The schema of a collection

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
admin
typesense collection_info "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books"
mentdb
{"created_at": 1794914647, "curation_sets": [], "default_sorting_field": "year", "enable_nested_fields": false, "fields": [{"facet": false, "index": true, "infix": false, "locale": "", "name": "title", "optional": false, "sort": false, "stem": false, "stem_dictionary": "", "store": true, "truncate_len": 100, "type": "string"}, {"facet": true, "index": true, "infix": false, "locale": "", "name": "author", "optional": false, "sort": false, "stem": false, "stem_dictionary": "", "store": true, "truncate_len": 100, "type": "string"}, {"facet": false, "index": true, "infix": false, "locale": "", "name": "year", "optional": false, "sort": true, "stem": false, "stem_dictionary": "", "store": true, "truncate_len": 100, "type": "int32"}, {"facet": false, "index": true, "infix": false, "locale": "", "name": "price", "optional": false, "sort": true, "stem": false, "stem_dictionary": "", "store": true, "truncate_len": 100, "type": "float"}], "name": "books", "num_documents": 4, "symbols_to_index": [], "synonym_sets": [], "token_separators": []}

typesense put <config> <collection> <id> <document_json>


Description

    Create or replace one document by id. Returns {id, result}

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    id:   The id - String - required
    document_json:   The document as a JSON object - String - required
admin
typesense put "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "6" "{\"title\": \"Candide\", \"author\": \"Voltaire\", \"year\": 1759, \"price\": 4.5}"
mentdb
{"id": "6", "result": "upsert"}

typesense put <config> <collection> <id> <document_json> <options_json>


Description

    Put with options: action (upsert, create, update, emplace)

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    id:   The id - String - required
    document_json:   The document as a JSON object - String - required
    options_json:   The options - String - required
admin
typesense put "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "6" "{\"price\": 5.0}" "{\"action\": \"update\"}"
mentdb
{"id": "6", "result": "update"}

typesense find <config> <collection> <filter_json>


Description

    The documents of a filter as rows (1000 by default)

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    filter_json:   The filter: {} for all; an object of equalities {"author": "Hugo", "year": [1831, 1862]}; or a filter_by text like year:<1860 && author:=Hugo - String - required
admin
typesense find "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "{\"author\": \"Hugo\"}"
mentdb
[{"author": "Hugo", "id": "1", "price": 12.5, "title": "Les Misérables", "year": 1862}, {"author": "Hugo", "id": "2", "price": 9.9, "title": "Notre-Dame de Paris", "year": 1831}]

typesense find <config> <collection> <filter_json> <options_json>


Description

    The documents of a filter with options: limit (1000, 1000000 at most), skip, sort ("year:desc"), fields

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    filter_json:   The filter: {} for all; an object of equalities {"author": "Hugo", "year": [1831, 1862]}; or a filter_by text like year:<1860 && author:=Hugo - String - required
    options_json:   The options: limit, skip, sort ("year:desc,title"), fields (a list or "a,b") - String - required
admin
typesense find "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "year:<1870" "{\"sort\": \"year:desc\", \"fields\": [\"id\", \"title\", \"year\"]}"
mentdb
[{"id": "1", "title": "Les Misérables", "year": 1862}, {"id": "3", "title": "Madame Bovary", "year": 1857}, {"id": "2", "title": "Notre-Dame de Paris", "year": 1831}, {"id": "6", "title": "Candide", "year": 1759}]

typesense count <config> <collection>


Description

    The number of documents

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
admin
typesense count "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books"
mentdb
5

typesense count <config> <collection> <filter_json>


Description

    The number of documents of a filter

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    filter_json:   The filter: {} for all; an object of equalities {"author": "Hugo", "year": [1831, 1862]}; or a filter_by text like year:<1860 && author:=Hugo - String - required
admin
typesense count "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "{\"author\": [\"Hugo\", \"Zola\"]}"
mentdb
3

typesense update <config> <collection> <filter_json> <changes_json>


Description

    Set fields on the documents of a filter (update by filter; the fields must exist in the schema or be automatic). Returns {matched, modified}

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    filter_json:   The filter: {} for all; an object of equalities {"author": "Hugo", "year": [1831, 1862]}; or a filter_by text like year:<1860 && author:=Hugo - String - required
    changes_json:   The fields to set, as a JSON object - String - required
admin
typesense update "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "{\"author\": \"Hugo\"}" "{\"price\": 10.0}"
mentdb
{"matched": 2, "modified": 2}

typesense update <config> <collection> <filter_json> <changes_json> <options_json>


Description

    Update with options (none yet)

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    filter_json:   The filter: {} for all; an object of equalities {"author": "Hugo", "year": [1831, 1862]}; or a filter_by text like year:<1860 && author:=Hugo - String - required
    changes_json:   The fields to set, as a JSON object - String - required
    options_json:   The options - String - required
admin
typesense update "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "year:>1870" "{\"price\": 8.0}" "{}"
mentdb
{"matched": 1, "modified": 1}

typesense get <config> <collection> <id>


Description

    A document, null if it does not exist

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    id:   The id - String - required
admin
typesense get "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "3"
mentdb
{"author": "Flaubert", "id": "3", "price": 7.2, "title": "Madame Bovary", "year": 1857}
no such id (fixed result: real Typesense 30.2)
admin
typesense get "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "99"
mentdb
null

typesense export <config> <collection>


Description

    All the documents of a collection as rows (JSONL export read line by line: the reading stops at the limit), 100000 at most by default

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
admin
typesense export "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "logs"
mentdb
[{"id": "1", "level": "info", "n": 1}, {"id": "2", "level": "error", "n": 2}]

typesense export <config> <collection> <options_json>


Description

    The export with options: filter_by, include_fields, exclude_fields, limit (100000, 1000000 at most)

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    options_json:   The options - String - required
admin
typesense export "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "{\"filter_by\": \"year:<1860\", \"include_fields\": [\"id\", \"title\"]}"
mentdb
[{"id": "2", "title": "Notre-Dame de Paris"}, {"id": "3", "title": "Madame Bovary"}, {"id": "6", "title": "Candide"}]

typesense delete <config> <collection> <id>


Description

    Delete a document by id: {deleted: 1}, or {deleted: 0} if it does not exist

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    id:   The id - String - required
admin
typesense delete "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "4"
mentdb
{"deleted": 1}
no such id (fixed result: real Typesense 30.2)
admin
typesense delete "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "404"
mentdb
{"deleted": 0}

typesense delete_where <config> <collection> <filter_json>


Description

    Delete the documents of a filter (not empty). Returns {deleted}

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    filter_json:   The filter: {} for all; an object of equalities {"author": "Hugo", "year": [1831, 1862]}; or a filter_by text like year:<1860 && author:=Hugo - String - required
admin
typesense delete_where "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "{\"author\": \"Flaubert\"}"
mentdb
{"deleted": 1}

typesense delete_where <config> <collection> <filter_json> <options_json>


Description

    Delete by filter with options: batch_size (documents deleted per batch on the server)

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    collection:   The collection name - String - required
    filter_json:   The filter: {} for all; an object of equalities {"author": "Hugo", "year": [1831, 1862]}; or a filter_by text like year:<1860 && author:=Hugo - String - required
    options_json:   The options - String - required
admin
typesense delete_where "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "books" "year:>1800" "{\"batch_size\": 100}"
mentdb
{"deleted": 2}

typesense request <config> <method> <path>


Description

    Any endpoint (path relative to the url): the JSON answer, or the text

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    method:   The HTTP method - String - required
    path:   The path with an optional query string - String - required
admin
typesense request "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "GET" "/collections/logs/documents/1"
mentdb
{"id": "1", "level": "info", "n": 1}

typesense request <config> <method> <path> <body_json>


Description

    Any endpoint with a JSON body (JSONL for /documents/import: one JSON per line)

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    method:   The HTTP method - String - required
    path:   The path - String - required
    body_json:   The body - String - required
admin
typesense request "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "PATCH" "/collections/logs/documents/1" "{\"level\": \"warning\"}"
mentdb
{"id": "1", "level": "warning", "n": 1}

typesense collection_drop <config> <name>


Description

    Delete a collection. Returns {dropped, existed}

Parameters

    config:   The configuration as JSON: url (http://localhost:8108), api_key (or api_key: sent in the X-TYPESENSE-API-KEY header), ca_file, insecure (localhost only), allow_plain, timeout_ms (30000), max_response_mb (64) - String - required
    name:   The collection name - String - required
admin
typesense collection_drop "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "logs"
mentdb
{"dropped": "logs", "existed": true}
no such collection (fixed result: real Typesense 30.2)
admin
typesense collection_drop "{\"url\": \"http://localhost:8108\", \"api_key\": \"typesense_key\"}" "logs-old"
mentdb
{"dropped": "logs-old", "existed": false}