A Typesense client: collections, documents, typo tolerant, faceted, grouped, vector and union search, synonyms, curation, API keys, analytics and clusters.
Types
Name Type Description descriptionstr = ""What the key is for. actionsVector<str>What it may do, such as documents:search or *. collectionsVector<str>Which collections it may use; * for all, and patterns such as org_.* work. expires_ati64 = 0A Unix time when it stops working; 0 for never. valuestr = ""The key text to use; empty lets the server make one. autodeletebool = falseDelete the key once it expires.
db-typesense-CreateKey.salam Copy
/*
* Salam Programming Language (2018-2026)
*
* +-------------------+
* | S A L A M |
* +-------------------+
*
* Designed by Seyyed Ali Mohammadiyeh and the Salam Team
*
* Repository: https://github.com/SalamLang/Salam
*
*/
import db.typesense
func main :
c := typesense. New ( "http://localhost:8108" , "admin-key" )
mut err := typesense.Error {}
mut books := Vector {} as Vector < str >
books. Push ( "books" )
search := typesense. SearchOnlyKey (c, "website search" , books, err)
println search.id, search.value, search.actions. Len (), search.collections. Get ( 0 )
mut actions := Vector {} as Vector < str >
actions. Push ( "documents:*" )
actions. Push ( "collections:get" )
mut orgs := Vector {} as Vector < str >
orgs. Push ( "org_.*" )
spec := typesense.KeySpec {
description = "tenant writer" ,
actions = actions,
collections = orgs,
expires_at = 1924992000 ,
autodelete = true
}
println typesense. KeySpecJSON (spec)
k := typesense. CreateKey (c, spec, err)
println k.value, k.expires_at, k.autodelete
mut all := Vector {} as Vector < str >
all. Push (typesense.KEY_ACTION_ALL)
admin := typesense. CreateKey (c, typesense.KeySpec {
description = "admin" ,
actions = all,
collections = all,
value = "my-chosen-admin-key"
}, err)
println admin.id
g := typesense. GetKey (c, k.id, err)
println g.value_prefix, g.description
each key in typesense. ListKeys (c, err):
println key.id,
key.value_prefix,
key.description,
key.actions. Len (),
key.collections. Len (),
key.expires_at
end
println typesense. DeleteKey (c, k.id, err)
scope := typesense.SearchParams { filter_by = "company_id:=124" , exclude_fields = "salary" }
scoped := typesense. ScopedSearchKey (search.value, scope, 1924992000 )
println scoped
println typesense. GenerateScopedSearchKey (search.value, `{"filter_by":"user_id:=42"}` )
mut browser := typesense. New ( "https://search.example.com" , scoped)
defer typesense. Free (browser)
println typesense. Search (browser, "books" , typesense. NewSearch ( "dune" , "title" ), err).found
println typesense.KEY_ACTION_SEARCH
end
Name Type Description idi64 = 0Its id. valuestr = ""The full key text; only returned when the key is created. value_prefixstr = ""The first characters of the key, returned when it is read back. descriptionstr = ""What it is for. actionsVector<str>What it may do. collectionsVector<str>Which collections it may use. expires_ati64 = 0When it stops working, as a Unix time. autodeletebool = falseWhether it is deleted once it expires.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
One field of a collection schema. Only the values you change are sent.
Name Type Description namestr = ""The field name, or a regular expression such as .*_facet. kindstr = ""Its type, one of the TYPE_ constants. facetbool = falseCount its values for facets and allow exact filters. optionalbool = falseDocuments may leave it out. indexbool = trueIndex it for search and filters; false keeps it stored only. storebool = trueKeep it on disk; false indexes it without storing it. sortint = 01 makes it sortable, -1 makes it not sortable, 0 keeps the default (numbers sort, text does not). infixbool = falseAllow matches in the middle of words. localestr = ""The language of the text, such as fa or en. stembool = falseMatch words by their root. stem_dictionarystr = ""A custom stemming dictionary to use. range_indexbool = falseIndex it for fast range filters. referencestr = ""Join to another collection, as collection.field. async_referencebool = falseAccept a reference to a document that does not exist yet. num_dimint = 0The size of the vector, for a float[] vector field. vec_diststr = ""The vector distance, cosine or ip. embedstr = ""How to make the vector automatically, as JSON; see EmbeddingField. token_separatorsVector<str>Extra characters that split words in this field. symbols_to_indexVector<str>Special characters to keep in this field. truncate_lenint = 0How many characters of a long string to index. dropbool = falseRemoves the field in UpdateCollection; used by DropFields. extrastr = ""More members as a JSON object, such as {"hnsw_params":{"M":16}}.
db-typesense-CreateCollection.salam Copy
/*
* Salam Programming Language (2018-2026)
*
* +-------------------+
* | S A L A M |
* +-------------------+
*
* Designed by Seyyed Ali Mohammadiyeh and the Salam Team
*
* Repository: https://github.com/SalamLang/Salam
*
*/
import db.typesense
func main :
c := typesense. New ( "http://localhost:8108" , "admin-key" )
mut err := typesense.Error {}
mut s := typesense.Schema {
name = "books_v2" , default_sorting_field = "year" , enable_nested_fields = true
}
s.fields. Push (typesense. NewField ( "title" , typesense.TYPE_STRING))
s.fields. Push (typesense.Field {
name = "title_fa" ,
kind = typesense.TYPE_STRING,
locale = "fa" ,
stem = true ,
optional = true
})
s.fields. Push (typesense. FacetField ( "year" , typesense.TYPE_INT32))
s.fields. Push (typesense. FacetField ( "genres" , typesense.TYPE_STRING_ARRAY))
s.fields. Push (
typesense.Field { name = "price" , kind = typesense.TYPE_FLOAT, range_index = true }
)
s.fields. Push (typesense.Field {
name = "isbn" ,
kind = typesense.TYPE_STRING,
index = false ,
optional = true
})
s.fields. Push (
typesense.Field {
name = "author_id" , kind = typesense.TYPE_STRING, reference = "authors.id"
}
)
s.fields. Push (
typesense.Field { name = "location" , kind = typesense.TYPE_GEOPOINT, optional = true }
)
s.fields. Push (typesense. VectorField ( "embedding" , 384 ))
mut from := Vector {} as Vector < str >
from. Push ( "title" )
s.fields. Push (typesense. EmbeddingField ( "title_vector" , from, "ts/all-MiniLM-L12-v2" ))
s.fields. Push (typesense.Field { name = "meta.*" , kind = typesense.TYPE_AUTO, optional = true })
s.symbols_to_index. Push ( "+" )
s.token_separators. Push ( "-" )
s.metadata = `{"owner": "catalog"}`
println typesense. SchemaJSON (s)
col := typesense. CreateCollection (c, s, err)
if typesense. IsConflict (err):
println "books_v2 already exists"
end
println col.name, col.num_documents, col.created_at, col.fields. Len ()
each f in col.fields:
println f.name, f.kind, f.facet, f.optional, f.sort, f.index, f.store
end
if typesense. CollectionExists (c, "books_v2" , err):
println typesense. GetCollection (c, "books_v2" , err).default_sorting_field
end
each x in typesense. ListCollections (c, err):
println x.name, x.num_documents
end
mut skip := Vector {} as Vector < str >
skip. Push ( "fields" )
println typesense. ListCollectionsPage (c, 0 , 20 , skip, err). Len ()
mut add := Vector {} as Vector <typesense.Field>
add. Push (
typesense. FacetField ( "publisher" , typesense.TYPE_STRING)
)
println typesense. AddFields (c, "books_v2" , add, err)
mut drop := Vector {} as Vector < str >
drop. Push ( "isbn" )
println typesense. DropFields (c, "books_v2" , drop, err)
println typesense. SetCollectionMetadata (c, "books_v2" , `{"owner": "search team"}` , err)
println typesense. UpdateCollection (c, "books_v2" , `{"synonym_sets": ["book-words"]}` , err)
a := typesense. UpsertAlias (c, "books" , "books_v2" , err)
println a.name, a.collection_name
println typesense. GetAlias (c, "books" , err).collection_name
each al in typesense. ListAliases (c, err):
println al.name, "->" , al.collection_name
end
println typesense. CloneCollection (c, "books_v2" , "books_v3" , err).name
println typesense. TruncateCollection (c, "books_v3" , err)
println typesense. DeleteCollection (c, "books_v3" , err).name
println typesense. DeleteAlias (c, "old_books" , err).name
println typesense. CreateCollectionJSON (
c, `{"name": "authors", "fields": [{"name": "name", "type": "string"}]}` , err
).name
println typesense. FieldJSON (typesense. NewField ( "pages" , typesense.TYPE_INT32))
println typesense.TYPE_STRING_ANY,
typesense.TYPE_INT32_ARRAY,
typesense.TYPE_INT64,
typesense.TYPE_INT64_ARRAY,
typesense.TYPE_FLOAT_ARRAY
println typesense.TYPE_BOOL,
typesense.TYPE_BOOL_ARRAY,
typesense.TYPE_GEOPOINT_ARRAY,
typesense.TYPE_GEOPOLYGON
println typesense.TYPE_OBJECT, typesense.TYPE_OBJECT_ARRAY, typesense.TYPE_IMAGE
end
A collection schema for CreateCollection.
Name Type Description namestr = ""The collection name. fieldsVector<Field>The fields. default_sorting_fieldstr = ""A numeric field to sort by when a search gives no sort order. enable_nested_fieldsbool = falseAllow object fields. token_separatorsVector<str>Extra characters that split words. symbols_to_indexVector<str>Special characters to keep, such as + for C++. synonym_setsVector<str>Synonym sets this collection uses (Typesense 30). curation_setsVector<str>Curation sets this collection uses (Typesense 30). metadatastr = ""Any JSON object to keep with the collection. voice_query_modelstr = ""The speech to text model for voice search, as JSON. extrastr = ""More members as a JSON object.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
A collection, as the server describes it.
Name Type Description namestr = ""Its name. num_documentsi64 = 0How many documents it holds. created_ati64 = 0When it was made, as a Unix time. default_sorting_fieldstr = ""The default sort field. enable_nested_fieldsbool = falseWhether object fields are allowed. fieldsVector<Field>Its fields, with every default filled in. token_separatorsVector<str>Extra word separators. symbols_to_indexVector<str>Special characters it keeps. synonym_setsVector<str>The synonym sets it uses. curation_setsVector<str>The curation sets it uses. metadatastr = ""Its metadata, as JSON. rawstr = ""The whole answer, as JSON.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
An alias: a second name that points to a collection.
Name Type Description namestr = ""The alias. collection_namestr = ""The collection it points to.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
An analytics rule, in the Typesense 30 form.
Name Type Description namestr = ""Its name. kindstr = ""One of the RULE_ constants. collectionstr = ""The collection whose events it collects. event_typestr = ""One of the EVENT_ constants. rule_tagstr = ""A tag to list rules by. paramsstr = ""The rule parameters, as JSON, such as {"destination_collection":"pq","limit":100}. rawstr = ""The whole rule, as JSON; the only place a Typesense 29 rule keeps its source and destination.
db-typesense-CreateAnalyticsRule.salam Copy
/*
* Salam Programming Language (2018-2026)
*
* +-------------------+
* | S A L A M |
* +-------------------+
*
* Designed by Seyyed Ali Mohammadiyeh and the Salam Team
*
* Repository: https://github.com/SalamLang/Salam
*
*/
import db.typesense
func main :
c := typesense. New ( "http://localhost:8108" , "admin-key" )
mut err := typesense.Error {}
popular := typesense.AnalyticsRule {
name = "popular-searches" ,
kind = typesense.RULE_POPULAR_QUERIES,
collection = "books" ,
event_type = typesense.EVENT_SEARCH,
params = `{"destination_collection": "popular_queries", "limit": 1000}`
}
println typesense. AnalyticsRuleJSON (popular)
made := typesense. CreateAnalyticsRule (c, popular, err)
println made.name, made.kind, made.collection, made.event_type, made.params
clicks := typesense.AnalyticsRule {
name = "book-clicks" ,
kind = typesense.RULE_COUNTER,
collection = "books" ,
event_type = typesense.EVENT_CLICK,
rule_tag = "homepage" ,
params = `{"destination_collection": "books", "counter_field": "popularity", "weight": 1}`
}
println typesense. UpsertAnalyticsRule (c, clicks, err).rule_tag
println typesense. CreateAnalyticsRuleJSON (
c,
`{"name": "no-results", "type": "nohits_queries", "collection": "books", "event_type": "search", "params": {"destination_collection": "nohits", "limit": 100}}` ,
err
)
println typesense. UpsertAnalyticsRuleJSON (
c,
"old-style" ,
`{"type": "popular_queries", "params": {"source": {"collections": ["books"]}, "destination": {"collection": "pq"}}}` ,
err
)
println typesense. GetAnalyticsRule (c, "book-clicks" , err).raw
each r in typesense. ListAnalyticsRules (c, "homepage" , err):
println r.name, r.kind
end
println typesense. SendEvent (
c, "book-clicks" , typesense.EVENT_CLICK, `{"doc_id": "42", "user_id": "u-7"}` , err
)
println typesense. SendEventJSON (
c,
`{"name": "book-clicks", "event_type": "click", "data": {"doc_id": "43", "user_id": "u-7"}}` ,
err
)
each e in typesense. GetEvents (c, "u-7" , "book-clicks" , 20 , err):
println e
end
println typesense. FlushAnalytics (c, err), typesense. AnalyticsStatus (c, err)
println typesense. DeleteAnalyticsRule (c, "no-results" , err)
println typesense.RULE_LOG,
typesense.EVENT_CONVERSION,
typesense.EVENT_VISIT,
typesense.EVENT_CUSTOM
m := typesense.ConversationModel {
id = "books-assistant" ,
model_name = "openai/gpt-4o-mini" ,
api_key = "sk-..." ,
history_collection = "conversations" ,
system_prompt = "You recommend books from our catalog." ,
max_bytes = 16384 ,
ttl = 86400 ,
account_id = "" ,
vllm_url = "" ,
extra = ""
}
println typesense. ConversationModelJSON (m)
println typesense. CreateConversationModel (c, m, err)
println typesense. GetConversationModel (c, "books-assistant" , err)
println typesense. ListConversationModels (c, err). Len ()
println typesense. UpdateConversationModel (
c,
"books-assistant" ,
typesense.ConversationModel { system_prompt = "Answer in one sentence." },
err
)
println typesense. DeleteConversationModel (c, "books-assistant" , err)
println typesense. CreateNLSearchModel (
c,
`{"id": "gpt-4o-nl", "model_name": "openai/gpt-4o-mini", "api_key": "sk-...", "max_bytes": 16000}` ,
err
)
println typesense. GetNLSearchModel (c, "gpt-4o-nl" , err)
println typesense. ListNLSearchModels (c, err). Len ()
println typesense. UpdateNLSearchModel (c, "gpt-4o-nl" , `{"temperature": 0.0}` , err)
println typesense. DeleteNLSearchModel (c, "gpt-4o-nl" , err)
end
A large language model for conversational search (RAG). Only the values you set are sent.
Name Type Description idstr = ""Its id. model_namestr = ""The model, such as openai/gpt-4o. api_keystr = ""The key for the model provider. history_collectionstr = ""The collection that keeps conversation history. system_promptstr = ""The instructions given to the model. max_bytesint = 0How much context the model receives. ttlint = 0How long a conversation is kept, in seconds. account_idstr = ""The account id, for Cloudflare models. vllm_urlstr = ""The server URL, for vLLM models. extrastr = ""More members as a JSON object.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
The parameters of one search. Zero values and empty strings are left out; anything else goes through Set.
Name Type Description qstr = ""The text to search for; * matches every document. query_bystr = ""The fields to search, comma separated. query_by_weightsstr = ""The weight of each field in query_by, such as 2,1. text_match_typestr = ""How field scores combine: max_score, max_weight or sum_score. prefixstr = ""Whether the last word matches as a prefix, one value per field such as true,false. infixstr = ""Infix search per field: off, always or fallback. filter_bystr = ""A filter, such as year:>2000 && genre:=[scifi]. sort_bystr = ""The sort order, such as year:desc,_text_match:desc. facet_bystr = ""Fields to count values of. facet_querystr = ""Narrow the facet values, such as genre:sci. max_facet_valuesint = 0How many values each facet returns. group_bystr = ""Group the results by these fields. group_limitint = 0How many hits each group returns. include_fieldsstr = ""Return only these fields. exclude_fieldsstr = ""Leave these fields out of the results. highlight_fieldsstr = ""Highlight only these fields. highlight_full_fieldsstr = ""Highlight the whole value of these fields, not a snippet. highlight_start_tagstr = ""The tag before a match; <mark> by default. highlight_end_tagstr = ""The tag after a match. snippet_thresholdint = 0Fields shorter than this many words are highlighted whole. num_typosstr = ""How many typos a word may have, 0 to 2, one value per field. typo_tokens_thresholdint = 0Look for typo matches only when fewer results than this were found. drop_tokens_thresholdint = 0Drop words from the query only when fewer results than this were found. pageint = 0The page, from 1. per_pageint = 0Hits per page, up to 250. offsetint = 0Skip this many hits; an alternative to page. limitint = 0Return this many hits; used with offset. pinned_hitsstr = ""Pin documents to positions, such as 12:1,3:2. hidden_hitsstr = ""Ids of documents to hide. override_tagsstr = ""Apply only the curation rules with these tags. presetstr = ""Use the parameters saved in this preset. vector_querystr = ""A nearest neighbour search, such as embedding:([0.1, 0.2], k: 10). stopwordsstr = ""A stopword set to apply. exhaustive_searchbool = falseConsider every variation of the query, slower but complete. search_cutoff_msint = 0Stop searching after this many milliseconds and return what was found. use_cachebool = falseCache the results on the server. cache_ttlint = 0How long to cache them, in seconds. conversationbool = falseAnswer the query with a conversation model (RAG). conversation_idstr = ""Continue this conversation. conversation_model_idstr = ""The conversation model to use. nl_querybool = falseTurn a natural language query into filters and sorting with an NL search model. nl_model_idstr = ""The NL search model to use. keysVector<str>Parameter names added with Set. valuesVector<str>Their values.
db-typesense-Search.salam Copy
/*
* Salam Programming Language (2018-2026)
*
* +-------------------+
* | S A L A M |
* +-------------------+
*
* Designed by Seyyed Ali Mohammadiyeh and the Salam Team
*
* Repository: https://github.com/SalamLang/Salam
*
*/
import str
import db.typesense
struct Book :
pub id: str = ""
pub title: str = ""
pub year: int = 0
end
func main :
c := typesense. New ( "http://localhost:8108" , "search-key" )
mut err := typesense.Error {}
mut p := typesense. NewSearch ( "dune" , "title,description" )
p.query_by_weights = "3,1"
p.filter_by = "year:>1950 && genres:=[scifi]"
p.sort_by = "_text_match:desc,year:desc"
p.facet_by = "genres,year"
p.max_facet_values = 10
p.per_page = 20
p. page = 1
p.num_typos = "2,1"
p.highlight_start_tag = "<b>"
p.highlight_end_tag = "</b>"
typesense. Set (p, "prioritize_exact_match" , "false" )
println typesense. SearchQuery (p)
println typesense. SearchParamsJSON (p)
r := typesense. Search (c, "books" , p, err)
if not typesense. Ok (err):
println typesense. ErrorString (err)
ret 1
end
println r.found, r.out_of, r. page , r.search_time_ms, r.search_cutoff
each h in r.hits:
println h.document, h.text_match, h.curated, typesense. Highlight (h, "title" )
println h.highlight,
h.highlights,
h.text_match_info,
h.vector_distance,
h.geo_distance_meters,
h.hybrid_search_info,
h.raw. Len ()
end
each f in r.facets:
print f.field_name, f.sampled, f.stats, ":"
each fc in f.counts:
print " " + fc.value + "=" + fc.count + " " + fc.highlighted
end
println ""
end
mut books := Vector {} as Vector <Book>
if typesense. HitsAs (r, books, err):
println books. Len ()
end
println r.request_params, r.raw. Len ()
mut g := typesense. NewSearch ( "*" , "" )
g.group_by = "genres"
g.group_limit = 3
g.include_fields = "id,title"
rg := typesense. Search (c, "books" , g, err)
println rg.found, rg.found_docs
each grp in rg.groups:
println str . Join (grp.key, "," ), grp.found, grp.hits. Len ()
end
mut v := typesense. NewSearch ( "*" , "" )
v.vector_query = "embedding:([0.12, 0.45, 0.87], k: 10)"
v.exclude_fields = "embedding"
println typesense. SearchRaw (c, "books" , v, err)
mut rag := typesense. NewSearch ( "which books are about deserts?" , "title_vector" )
rag.conversation = true
rag.conversation_model_id = "books-assistant"
rag.conversation_id = ""
rag.prefix = "false"
rag.exhaustive_search = true
rag.search_cutoff_ms = 200
rag.use_cache = true
rag.cache_ttl = 60
println typesense. Search (c, "books" , rag, err).conversation
mut nl := typesense. NewSearch ( "science fiction books after 1960 sorted by year" , "title" )
nl.nl_query = true
nl.nl_model_id = "gpt-4o-nl"
println typesense. Search (c, "books" , nl, err).parsed_nl_query
mut reqs := Vector {} as Vector <typesense.SearchRequest>
reqs. Push (
typesense.SearchRequest { collection = "books" , params = typesense. NewSearch ( "dune" , "" ) }
)
reqs. Push (
typesense.SearchRequest {
collection = "authors" ,
params = typesense. NewSearch ( "herbert" , "name" ),
api_key = "scoped-key"
}
)
common := typesense. NewSearch ( "" , "title" )
each m in typesense. MultiSearch (c, reqs, common, err):
println m.found, m.code, m.error
end
println typesense. MultiSearchRaw (c, reqs, common, err). Len ()
u := typesense. UnionSearch (c, reqs, common, err)
each h in u.hits:
println h.collection, h.search_index, h.document
end
mut rr := typesense. ParseSearchResult ( `{"found": 0, "hits": []}` )
println rr.found, rr.code, rr.error, typesense.MAX_GET_QUERY
typesense. FreeResult (rr)
end
One search of a multi search.
Name Type Description collectionstr = ""The collection to search. paramsSearchParamsIts parameters. api_keystr = ""A different API key for this search only, such as a scoped key.
The example for this item is shown with the ones above: db-typesense-Search.salam
Name Type Description documentstr = ""The document, as JSON. text_matchi64 = 0The text relevance score. highlightstr = ""The highlights by field, as JSON; read one with Highlight. highlightsstr = ""The highlights in the older list form, as JSON. text_match_infostr = ""How the score was made, as JSON. geo_distance_metersstr = ""The distance from a geo sort point, as JSON. vector_distancef64 = 0The distance from the query vector. hybrid_search_infostr = ""How a hybrid search ranked it, as JSON. curatedbool = falseIt was placed by a curation rule. collectionstr = ""The collection it came from, in a union search. search_indexint = 0Which search of a union search found it, from 0. rawstr = ""The whole hit, as JSON.
The example for this item is shown with the ones above: db-typesense-Search.salam
Name Type Description valuestr = ""The value. counti64 = 0How many hits have it. highlightedstr = ""The value with the facet query highlighted.
The example for this item is shown with the ones above: db-typesense-Search.salam
The value counts of one field.
Name Type Description field_namestr = ""The field. countsVector<FacetCount>The values, most common first. sampledbool = falseThe counts were estimated from a sample. statsstr = ""Minimum, maximum, sum and average of a number field, as JSON.
The example for this item is shown with the ones above: db-typesense-Search.salam
The hits that share a value of group_by.
Name Type Description keyVector<str>The values that make the group. foundi64 = 0How many hits the group has. hitsVector<Hit>Its hits, up to group_limit.
The example for this item is shown with the ones above: db-typesense-Search.salam
Name Type Description foundi64 = 0How many documents matched, or how many groups when grouping. found_docsi64 = 0How many documents matched, when grouping. out_ofi64 = 0How many documents were searched. pageint = 0The page. search_time_msi64 = 0How long the search took. search_cutoffbool = falseThe search stopped at search_cutoff_ms. hitsVector<Hit>The hits. groupsVector<Group>The groups, when grouping. facetsVector<Facet>The facet counts. request_paramsstr = ""The parameters the server used, as JSON. conversationstr = ""The conversation answer, as JSON. parsed_nl_querystr = ""What a natural language query was turned into, as JSON. codeint = 0In a multi search, the HTTP status of this search when it failed. errorstr = ""In a multi search, why this search failed. rawstr = ""The whole answer, as JSON.
The example for this item is shown with the ones above: db-typesense-Search.salam
A synonym: words that should find each other.
Name Type Description idstr = ""Its id. synonymsVector<str>The words. Without a root they all mean the same thing. rootstr = ""When set, a search for the root also finds the other words, but not the other way round. localestr = ""The language of the words, such as fa. symbols_to_indexVector<str>Special characters the words contain that should be kept.
db-typesense-UpsertSynonymSet.salam Copy
/*
* Salam Programming Language (2018-2026)
*
* +-------------------+
* | S A L A M |
* +-------------------+
*
* Designed by Seyyed Ali Mohammadiyeh and the Salam Team
*
* Repository: https://github.com/SalamLang/Salam
*
*/
import db.typesense
func main :
c := typesense. New ( "http://localhost:8108" , "admin-key" )
mut err := typesense.Error {}
mut words := Vector {} as Vector < str >
words. Push ( "book" )
words. Push ( "novel" )
words. Push ( "کتاب" )
mut items := Vector {} as Vector <typesense.Synonym>
items. Push (
typesense.Synonym { id = "books" , synonyms = words }
)
set := typesense. UpsertSynonymSet (c, "book-words" , items, err)
println set.name, set.items. Len ()
mut one := Vector {} as Vector < str >
one. Push ( "paperback" )
s := typesense.Synonym {
id = "paper" ,
root = "book" ,
synonyms = one,
locale = "en" ,
symbols_to_index = Vector {} as Vector < str >
}
println typesense. SynonymJSON (s)
println typesense. UpsertSynonymItem (c, "book-words" , s, err).root
println typesense. GetSynonymItem (c, "book-words" , "paper" , err).synonyms. Len ()
println typesense. ListSynonymItems (c, "book-words" , err). Len (),
typesense. GetSynonymSet (c, "book-words" , err).items. Len (),
typesense. ListSynonymSets (c, err). Len ()
println typesense. DeleteSynonymItem (c, "book-words" , "paper" , err)
println typesense. UpsertSynonym (c, "books" , s, err).id
println typesense. GetSynonym (c, "books" , "paper" , err).root,
typesense. ListSynonyms (c, "books" , err). Len ()
println typesense. DeleteSynonym (c, "books" , "paper" , err)
mut pins := Vector {} as Vector <typesense.Pin>
pins. Push (
typesense.Pin { id = "42" , position = 1 }
)
mut hide := Vector {} as Vector < str >
hide. Push ( "13" )
mut tags := Vector {} as Vector < str >
tags. Push ( "summer-sale" )
rule := typesense.CurationRule {
id = "promote-dune" ,
query = "dune" ,
match_type = typesense.MATCH_EXACT,
includes = pins,
excludes = hide,
filter_curated_hits = true ,
effective_from_ts = 1924992000 ,
metadata = `{"campaign": "summer"}`
}
println typesense. CurationJSON (rule)
mut rules := Vector {} as Vector <typesense.CurationRule>
rules. Push (rule)
rules. Push (typesense.CurationRule {
id = "sale" ,
tags = tags,
rule_filter_by = "on_sale:=true" ,
filter_by = "stock:>0" ,
sort_by = "price:asc" ,
match_type = typesense.MATCH_CONTAINS,
replace_query = "" ,
remove_matched_tokens = true ,
stop_processing = false ,
effective_to_ts = 1956528000 ,
extra = ""
})
cs := typesense. UpsertCurationSet (c, "promotions" , rules, err)
println cs.name, cs.items. Len ()
println typesense. UpsertCurationItem (c, "promotions" , rule, err).id
println typesense. GetCurationItem (c, "promotions" , "sale" , err).sort_by,
typesense. ListCurationItems (c, "promotions" , err). Len ()
println typesense. GetCurationSet (c, "promotions" , err).items. Len (),
typesense. ListCurationSets (c, err). Len ()
println typesense. DeleteCurationItem (c, "promotions" , "sale" , err)
println typesense. UpdateCollection (
c, "books" , `{"synonym_sets": ["book-words"], "curation_sets": ["promotions"]}` , err
)
println typesense. UpsertOverride (c, "books" , rule, err).id
println typesense. GetOverride (c, "books" , "promote-dune" , err).query,
typesense. ListOverrides (c, "books" , err). Len ()
println typesense. DeleteOverride (c, "books" , "promote-dune" , err)
mut listing := typesense. NewSearch ( "" , "title,description" )
listing.per_page = 24
listing.sort_by = "popularity:desc"
pr := typesense. UpsertSearchPreset (c, "listing" , listing, err)
println pr.name, pr.value
println typesense. UpsertPreset (c, "listing-raw" , `{"query_by": "title"}` , err).value
println typesense. GetPreset (c, "listing" , err).value
each x in typesense. ListPresets (c, err):
println x.name
end
println typesense. DeletePreset (c, "listing-raw" , err)
mut sw := Vector {} as Vector < str >
sw. Push ( "the" )
sw. Push ( "a" )
st := typesense. UpsertStopwords (c, "english" , sw, "en" , err)
println st.id, st.locale, st.stopwords. Len ()
println typesense. GetStopwords (c, "english" , err).stopwords. Len (),
typesense. ListStopwords (c, err). Len ()
println typesense. DeleteStopwords (c, "english" , err)
mut stem := Vector {} as Vector <typesense.StemWord>
stem. Push (
typesense.StemWord { word = "mice" , root = "mouse" }
)
stem. Push (typesense.StemWord { word = "geese" , root = "goose" })
println typesense. ImportStemmingDictionary (c, "irregular" , stem, err)
println typesense. ImportStemmingJSONL (c, "irregular" , `{"word": "teeth", "root": "tooth"}` , err)
d := typesense. GetStemmingDictionary (c, "irregular" , err)
println d.id, d.words. Len ()
println typesense. ListStemmingDictionaries (c, err). Len ()
println typesense. DeleteStemmingDictionary (c, "irregular" , err)
println typesense. DeleteCurationSet (c, "promotions" , err),
typesense. DeleteSynonymSet (c, "book-words" , err)
end
A named set of synonyms, shared by any collection that lists it (Typesense 30).
Name Type Description namestr = ""Its name. itemsVector<Synonym>The synonyms.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
A document pinned to a position in the results.
Name Type Description idstr = ""The document id. positionint = 0The position, from 1.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
A curation rule (called an override before Typesense 30): when a query matches, pin, hide, filter or sort the results.
Name Type Description idstr = ""Its id. querystr = ""The query text it matches. match_typestr = ""MATCH_EXACT or MATCH_CONTAINS. rule_filter_bystr = ""Apply the rule when the search uses this filter. tagsVector<str>Apply the rule when the search sends one of these tags in override_tags. includesVector<Pin>Documents to pin. excludesVector<str>Ids of documents to hide. filter_bystr = ""A filter to add to the search. sort_bystr = ""A sort order to use instead. replace_querystr = ""A query to search for instead. remove_matched_tokensbool = falseRemove the matched words from the query. filter_curated_hitsbool = falseApply the search filter to the pinned documents too. stop_processingbool = trueStop at this rule when it matches; false lets later rules apply too. effective_from_tsi64 = 0A Unix time before which the rule does nothing; 0 for always. effective_to_tsi64 = 0A Unix time after which the rule does nothing; 0 for never. metadatastr = ""Any JSON object to return with the results when the rule applies. extrastr = ""More members as a JSON object, merged into the rule as they are.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
A named set of curation rules, shared by any collection that lists it (Typesense 30).
Name Type Description namestr = ""Its name. itemsVector<CurationRule>The rules.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
Saved search parameters, used with SearchParams.preset.
Name Type Description namestr = ""Its name. valuestr = ""The parameters, as JSON.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
A set of words to ignore in queries.
Name Type Description idstr = ""Its id, used in SearchParams.stopwords. stopwordsVector<str>The words. localestr = ""Their language.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
One word and the root it reduces to.
Name Type Description wordstr = ""The word. rootstr = ""Its root.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
struct StemmingDictionary A custom stemming dictionary, used with Field.stem_dictionary.
Name Type Description idstr = ""Its id. wordsVector<StemWord>The words.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
Options for writing documents. Empty fields are left out.
Name Type Description actionstr = ""One of the ACTION_ constants; empty means create. dirty_valuesstr = ""One of the DIRTY_ constants. batch_sizeint = 0How many documents the server indexes at once during an import. return_idbool = falseInclude the id of each document in the import result. return_docbool = falseInclude each document in the import result. remote_embedding_batch_sizeint = 0How many documents to send to a remote embedding model at once.
db-typesense-ImportDocuments.salam Copy
/*
* Salam Programming Language (2018-2026)
*
* +-------------------+
* | S A L A M |
* +-------------------+
*
* Designed by Seyyed Ali Mohammadiyeh and the Salam Team
*
* Repository: https://github.com/SalamLang/Salam
*
*/
import db.typesense
struct Book :
pub id: str = ""
pub title: str = ""
pub year: int = 0
end
func main :
c := typesense. New ( "http://localhost:8108" , "admin-key" )
mut err := typesense.Error {}
println typesense. CreateDocument (c, "books" , `{"id": "1", "title": "Dune", "year": 1965}` , err)
println typesense. UpsertDocument (c, "books" , `{"id": "1", "title": "Dune", "year": 1965}` , err)
println typesense. EmplaceDocument (c, "books" , `{"id": "2", "title": "Emma"}` , err)
println typesense. UpdateDocument (c, "books" , "2" , `{"year": 1815}` , err)
println typesense. UpdateDocumentWith (
c, "books" , "2" , `{"year": "1815"}` , typesense.DIRTY_COERCE_OR_REJECT, err
)
println typesense. IndexDocument (
c,
"books" ,
`{"id": "3", "title": "Ulysses", "year": "1922"}` ,
typesense.WriteOptions {
action = typesense.ACTION_UPSERT, dirty_values = typesense.DIRTY_COERCE_OR_DROP
},
err
)
println typesense. GetDocument (c, "books" , "1" , err)
println typesense. DocumentExists (c, "books" , "42" , err)
mut b := Book {}
if typesense. GetDocumentAs (c, "books" , "1" , b, err):
println b.title, b.year
end
println typesense. CreateDocumentOf (
c, "books" , Book { id = "4" , title = "Beloved" , year = 1987 }, err
)
println typesense. UpsertDocumentOf (
c, "books" , Book { id = "4" , title = "Beloved" , year = 1987 }, err
)
mut books := Vector {} as Vector <Book>
books. Push (
Book { id = "5" , title = "Hamlet" , year = 1603 }
)
books. Push (Book { id = "6" , title = "Middlemarch" , year = 1871 })
r := typesense. ImportOf (
c,
"books" ,
books,
typesense.WriteOptions {
action = typesense.ACTION_UPSERT, batch_size = 100 , return_id = true
},
err
)
println r.success, r.failed, r.ids. Len (), r.documents. Len (), r.lines. Len ()
each e in r.errors:
println e.line, e.id, e.code, e.error, e.document
end
mut docs := Vector {} as Vector < str >
docs. Push (
`{"id": "7", "title": "Persuasion", "year": 1817}`
)
docs. Push ( `{"id": "8", "title": "Walden", "year": "1854"}` )
r2 := typesense. ImportDocuments (
c,
"books" ,
docs,
typesense.WriteOptions {
action = typesense.ACTION_CREATE,
dirty_values = typesense.DIRTY_REJECT,
return_doc = true
},
err
)
println r2.success, r2.failed
r3 := typesense. ImportJSONL (
c,
"books" ,
"{\"id\": \"9\", \"title\": \"Emma\"}\n" ,
typesense.WriteOptions {
action = typesense.ACTION_UPDATE, remote_embedding_batch_size = 50
},
err
)
println r3.success, typesense.ACTION_EMPLACE, typesense.DIRTY_DROP
println typesense. UpdateByFilter (c, "books" , "year:<1900" , `{"classic": true}` , err)
println typesense. DeleteByFilter (c, "books" , "year:<1700" , 500 , err)
println typesense. DeleteDocument (c, "books" , "9" , err)
lines := typesense. ExportDocuments (
c,
"books" ,
typesense.ExportOptions {
filter_by = "year:>1800" , include_fields = "id,title,year" , exclude_fields = ""
},
err
)
mut back := Vector {} as Vector <Book>
if typesense. DecodeDocuments (lines, back, err):
println back. Len ()
end
mut one := Book {}
println typesense. DecodeDocument ( `{"id": "1", "title": "Dune", "year": 1965}` , one, err),
one.title
println typesense. ExportJSONL (c, "books" , typesense.ExportOptions {}, err). Len ()
end
One line of an import that failed.
Name Type Description lineint = 0Its position in the import, from 0. idstr = ""The document id, when return_id was set. codeint = 0The HTTP status for this line, such as 400 or 409. errorstr = ""The reason it failed. documentstr = ""The document text, when return_doc was set.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
The result of an import. Typesense answers 200 even when some lines fail, so check failed.
Name Type Description successint = 0How many documents were written. failedint = 0How many were not. idsVector<str>The ids of the written documents, with return_id. documentsVector<str>The written documents, with return_doc. errorsVector<ImportError>The lines that failed. linesVector<str>The raw result line of every document.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
Which documents to export and which fields.
Name Type Description filter_bystr = ""A filter, such as year:>2000; empty exports all. include_fieldsstr = ""Export only these fields, comma separated. exclude_fieldsstr = ""Leave these fields out, comma separated.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
A connection to a Typesense server or cluster. Build it with New or NewCluster and release it with Free.
Name Type Description nodesVector<str>The node URLs, such as http://localhost:8108; a path after the host is kept as a prefix. neareststr = ""A node to try before the others, such as the one in the same region; empty for none. api_keystr = ""The key sent in the X-TYPESENSE-API-KEY header. timeout_msint = 10000How long one request may take, in milliseconds; 0 waits forever. retriesint = 3How many more times to try after a node fails. retry_interval_msint = 100The pause between two tries, in milliseconds. healthcheck_msint = 60000How long a node that failed is skipped, in milliseconds. headersVector<str>Extra header lines added with AddHeader. stateVector<i64>Internal: the round robin position and when each node may be tried again.
db-typesense-Client.salam Copy
/*
* Salam Programming Language (2018-2026)
*
* +-------------------+
* | S A L A M |
* +-------------------+
*
* Designed by Seyyed Ali Mohammadiyeh and the Salam Team
*
* Repository: https://github.com/SalamLang/Salam
*
*/
import db.typesense
func main :
mut nodes := Vector {} as Vector < str >
nodes. Push ( "http://ts-1:8108" )
nodes. Push ( "http://ts-2:8108" )
nodes. Push ( "http://ts-3:8108" )
mut c := typesense. NewCluster (nodes, "admin-key" )
defer typesense. Free (c)
typesense. SetNearestNode (c, "http://ts-local:8108" )
typesense. AddNode (c, "http://ts-4:8108" )
typesense. AddHeader (c, "X-Request-Source" , "salam" )
c.timeout_ms = 5000
c.retries = 2
c.retry_interval_ms = 200
c.healthcheck_ms = 30000
mut err := typesense.Error {}
if not typesense. Health (c, err):
println "not ready: " + typesense. ErrorString (err)
ret 1
end
println typesense. IsHealthy (c), typesense. NodeHealthy (c, 0 ), typesense. NodeHealthy (c, - 1 )
println "server" , typesense. ServerVersion (c, err), typesense. Debug (c, err)
st := typesense. Status (c, err)
println st.state, st.committed_index, st.queued_writes
println typesense. Stats (c, err)
println typesense. Metrics (c, err)
println typesense. CreateSnapshot (c, "/data/snapshots/today" , err)
println typesense. Vote (c, err),
typesense. ClearCache (c, err),
typesense. CompactDB (c, err),
typesense. ResetPeers (c, err)
println typesense. SchemaChanges (c, err). Len ()
println typesense. SetSlowRequestLog (c, 1000 , err),
typesense. UpdateConfig (c, `{"healthy-read-lag": 1000}` , err)
body := typesense. Request (c, "GET" , "/collections?limit=1" , "" , err)
if not typesense. Ok (err):
println err.status, err.kind, err.message
println err.kind == typesense.KIND_HTTP,
err.kind == typesense.KIND_NETWORK,
err.kind == typesense.KIND_INVALID,
err.kind == typesense.KIND_DECODE
println typesense. IsNotFound (err), typesense. IsConflict (err)
ret 1
end
println body
println typesense. RequestAs (
c,
"POST" ,
"/stemming/dictionaries/import?id=plurals" ,
"text/plain" ,
`{"word":"mice","root":"mouse"}` ,
err
)
println typesense.VERSION,
c.nodes. Len (),
c.nearest,
c.api_key. Len (),
c.headers. Len (),
c.state. Len ()
single := typesense. New ( "localhost:8108" , "admin-key" )
println single.nodes. Get ( 0 )
end
What went wrong in the last call. Empty when the call worked.
Name Type Description statusint = 0The HTTP status, or 0 when there was no answer. kindstr = ""One of the KIND_ constants, or empty when the call worked. messagestr = ""The message from the server, or a description of the failure.
The example for this item is shown with the ones above: db-typesense-Client.salam
The raft state of the node that answered.
Name Type Description statestr = ""LEADER, FOLLOWER or another raft state. committed_indexi64 = 0The last committed raft index. queued_writesi64 = 0Writes waiting to be applied.
The example for this item is shown with the ones above: db-typesense-Client.salam
Constants and variables
const KEY_ACTION_ALL: str = "*" Every action, for an admin key.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
const KEY_ACTION_SEARCH: str = "documents:search" Searching only, for a key a browser can hold.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
const TYPE_STRING: str = "string" The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_STRING_ARRAY: str = "string[]" The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_STRING_ANY: str = "string*" Text or a list of text, whichever each document has.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_INT32: str = "int32" The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_INT32_ARRAY: str = "int32[]" A list of 32 bit integers.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_INT64: str = "int64" A 64 bit integer, such as a Unix time in milliseconds.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_INT64_ARRAY: str = "int64[]" A list of 64 bit integers.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_FLOAT: str = "float" The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_FLOAT_ARRAY: str = "float[]" A list of floating point numbers; with num_dim it is a vector.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_BOOL: str = "bool" The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_BOOL_ARRAY: str = "bool[]" A list of true or false values.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_GEOPOINT: str = "geopoint" A latitude and longitude, written as [lat, lng].
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_GEOPOINT_ARRAY: str = "geopoint[]" The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_GEOPOLYGON: str = "geopolygon" An area on the map, for searching which areas contain a point.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_OBJECT: str = "object" A nested object; needs enable_nested_fields.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_OBJECT_ARRAY: str = "object[]" A list of nested objects.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_IMAGE: str = "image" An image, for image search with a CLIP model.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const TYPE_AUTO: str = "auto" Let Typesense guess the type from the first document, often used with a name pattern such as .*.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
const RULE_POPULAR_QUERIES: str = "popular_queries" A rule that collects the most searched queries into a collection.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const RULE_NOHITS_QUERIES: str = "nohits_queries" A rule that collects queries that found nothing.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const RULE_COUNTER: str = "counter" A rule that counts events into a field, such as clicks into a popularity score.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const RULE_LOG: str = "log" A rule that keeps every event.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const EVENT_SEARCH: str = "search" The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const EVENT_CLICK: str = "click" The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const EVENT_CONVERSION: str = "conversion" A purchase or another goal.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const EVENT_VISIT: str = "visit" A visit to a document page.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const EVENT_CUSTOM: str = "custom" The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
const MAX_GET_QUERY: i32 = 4000 A search query string longer than this many bytes is sent through /multi_search instead, as servers limit the length of a URL.
The example for this item is shown with the ones above: db-typesense-Search.salam
const MATCH_EXACT: str = "exact" A curation rule that applies when the query is exactly its text.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
const MATCH_CONTAINS: str = "contains" A curation rule that applies when the query contains its text.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
const ACTION_CREATE: str = "create" Index a new document; fail when the id exists.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
const ACTION_UPSERT: str = "upsert" Create the document, or replace the one with the same id.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
const ACTION_UPDATE: str = "update" Change the given fields of an existing document; fail when it does not exist.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
const ACTION_EMPLACE: str = "emplace" Create the document, or update the given fields when it exists.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
const DIRTY_COERCE_OR_REJECT: str = "coerce_or_reject" Turn a value of the wrong type into the field type, and reject the document when that is not possible.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
const DIRTY_COERCE_OR_DROP: str = "coerce_or_drop" Turn a value of the wrong type into the field type, and drop the field when that is not possible.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
const DIRTY_DROP: str = "drop" Drop fields whose value has the wrong type.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
const DIRTY_REJECT: str = "reject" Reject documents with a value of the wrong type.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
const VERSION: str = "1.0.0" The version of this client, sent in the User-Agent header.
The example for this item is shown with the ones above: db-typesense-Client.salam
const KIND_HTTP: str = "http" Error.kind when the server answered with an error status.
The example for this item is shown with the ones above: db-typesense-Client.salam
const KIND_NETWORK: str = "network" Error.kind when no node could be reached, or a request timed out.
The example for this item is shown with the ones above: db-typesense-Client.salam
const KIND_INVALID: str = "invalid" Error.kind when the client itself is unusable, such as having no nodes.
The example for this item is shown with the ones above: db-typesense-Client.salam
const KIND_DECODE: str = "decode" Error.kind when a document could not be read into your struct.
The example for this item is shown with the ones above: db-typesense-Client.salam
Functions
func KeySpecJSON (spec: KeySpec): str The JSON body for a key spec.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
func CreateKey (c: Client, spec: KeySpec, err &: Error): Key Creates an API key; the returned value is the only time the full key is shown.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
func SearchOnlyKey (c: Client, description: str , collections: Vector < str >, err &: Error): Key Creates a key that may only search the given collections.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
func GetKey (c: Client, id: i64 , err &: Error): Key One key, by id; only its prefix comes back.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
func ListKeys (c: Client, err &: Error): Vector <Key> The example for this item is shown with the ones above: db-typesense-CreateKey.salam
func DeleteKey (c: Client, id: i64 , err &: Error): i64 Deletes a key and returns its id.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
func GenerateScopedSearchKey (search_key: str , embedded_params: str ): str Signs a scoped search key from a search key and embedded search parameters as JSON, with no request to the server. The parameters, such as a filter_by and an expires_at, are applied to every search made with it and cannot be changed by the browser.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
func ScopedSearchKey (search_key: str , p: SearchParams, expires_at: i64 ): str GenerateScopedSearchKey with the parameters taken from a SearchParams; 0 for no expiry.
The example for this item is shown with the ones above: db-typesense-CreateKey.salam
func NewField (name: str , kind: str ): Field A field with a name and a type.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func FacetField (name: str , kind: str ): Field A field with facets turned on.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func VectorField (name: str , num_dim: int ): Field A float[] vector field of the given size.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func EmbeddingField (name: str , from: Vector < str >, model_name: str ): Field A vector field that Typesense fills by running a model on other fields, such as ts/all-MiniLM-L12-v2.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func FieldJSON (f: Field): str The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func SchemaJSON (s: Schema): str The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func CreateCollection (c: Client, schema: Schema, err &: Error): Collection Creates a collection from a schema.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func CreateCollectionJSON (c: Client, schema: str , err &: Error): Collection Creates a collection from a schema written as JSON.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func CloneCollection (c: Client, source: str , name: str , err &: Error): Collection Makes a new, empty collection with the schema of another.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func GetCollection (c: Client, name: str , err &: Error): Collection The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func CollectionExists (c: Client, name: str , err &: Error): bool Whether a collection exists.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func ListCollections (c: Client, err &: Error): Vector <Collection> The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func ListCollectionsPage (c: Client, offset: int , limit: int , exclude_fields: Vector < str >, err &: Error): Vector <Collection> A page of collections; 0 means no offset or no limit, and exclude_fields such as fields makes the answer smaller.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func UpdateCollection (c: Client, name: str , changes: str , err &: Error): str Changes a collection with a JSON body: fields to add or drop, metadata, synonym and curation sets.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func AddFields (c: Client, name: str , fields: Vector <Field>, err &: Error): str Adds fields to a collection; existing documents are indexed again.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func DropFields (c: Client, name: str , fields: Vector < str >, err &: Error): str Removes fields from a collection by name.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func SetCollectionMetadata (c: Client, name: str , metadata: str , err &: Error): str Replaces the metadata of a collection.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func DeleteCollection (c: Client, name: str , err &: Error): Collection Deletes a collection and all its documents.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func TruncateCollection (c: Client, name: str , err &: Error): i64 Deletes every document but keeps the collection, and returns how many were deleted.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func UpsertAlias (c: Client, name: str , collection: str , err &: Error): Alias Points an alias at a collection; moving it is the way to switch to a rebuilt collection with no downtime.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func GetAlias (c: Client, name: str , err &: Error): Alias The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func ListAliases (c: Client, err &: Error): Vector <Alias> The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func DeleteAlias (c: Client, name: str , err &: Error): Alias Deletes an alias, not the collection.
The example for this item is shown with the ones above: db-typesense-CreateCollection.salam
func AnalyticsRuleJSON (r: AnalyticsRule): str The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func CreateAnalyticsRuleJSON (c: Client, rule: str , err &: Error): str Creates a rule from JSON, in the form your server expects.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func UpsertAnalyticsRuleJSON (c: Client, name: str , rule: str , err &: Error): str Creates or replaces a rule by name, from JSON.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func CreateAnalyticsRule (c: Client, r: AnalyticsRule, err &: Error): AnalyticsRule The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func UpsertAnalyticsRule (c: Client, r: AnalyticsRule, err &: Error): AnalyticsRule Creates or replaces a rule.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func GetAnalyticsRule (c: Client, name: str , err &: Error): AnalyticsRule The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func ListAnalyticsRules (c: Client, rule_tag: str , err &: Error): Vector <AnalyticsRule> Every rule, or only those with a tag; reads both the Typesense 29 and 30 answers.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func DeleteAnalyticsRule (c: Client, name: str , err &: Error): str Deletes a rule and returns its name.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func SendEventJSON (c: Client, event: str , err &: Error): bool Sends an event written as JSON.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func SendEvent (c: Client, name: str , event_type: str , data: str , err &: Error): bool Sends an event to the rule with this name, with its data as JSON, such as {"doc_id":"1","user_id":"u1"}.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func GetEvents (c: Client, user_id: str , name: str , n: int , err &: Error): Vector < str > The latest events of a user for a rule, one JSON object each.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func FlushAnalytics (c: Client, err &: Error): bool Writes the collected analytics to their collections now.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func AnalyticsStatus (c: Client, err &: Error): str Counts of the events waiting to be written, as JSON.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func ConversationModelJSON (m: ConversationModel): str The JSON of a conversation model.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func CreateConversationModel (c: Client, m: ConversationModel, err &: Error): str Creates a conversation model; the server checks the key with the provider.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func GetConversationModel (c: Client, id: str , err &: Error): str One conversation model, as JSON.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func ListConversationModels (c: Client, err &: Error): Vector < str > Every conversation model, one JSON object each.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func UpdateConversationModel (c: Client, id: str , m: ConversationModel, err &: Error): str Changes a conversation model.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func DeleteConversationModel (c: Client, id: str , err &: Error): str Deletes a conversation model.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func CreateNLSearchModel (c: Client, model: str , err &: Error): str Creates a natural language search model from JSON.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func GetNLSearchModel (c: Client, id: str , err &: Error): str One NL search model, as JSON.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func ListNLSearchModels (c: Client, err &: Error): Vector < str > Every NL search model, one JSON object each.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func UpdateNLSearchModel (c: Client, id: str , model: str , err &: Error): str Changes an NL search model.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func DeleteNLSearchModel (c: Client, id: str , err &: Error): str Deletes an NL search model.
The example for this item is shown with the ones above: db-typesense-CreateAnalyticsRule.salam
func NewSearch (q: str , query_by: str ): SearchParams Search parameters with a query and the fields to search.
The example for this item is shown with the ones above: db-typesense-Search.salam
func Set (p &: SearchParams, key: str , value: str ) Sets any parameter by name, replacing an earlier value; for parameters without a field, such as prioritize_exact_match, or enable_curations set to false to switch off curation rules for one search ( enable_overrides on Typesense 29).
The example for this item is shown with the ones above: db-typesense-Search.salam
func SearchQuery (p: SearchParams): str The parameters as a URL query string.
The example for this item is shown with the ones above: db-typesense-Search.salam
func SearchParamsJSON (p: SearchParams): str The parameters as a JSON object.
The example for this item is shown with the ones above: db-typesense-Search.salam
func ParseSearchResult (body: str ): SearchResult Reads a search answer you got some other way.
The example for this item is shown with the ones above: db-typesense-Search.salam
func SearchRaw (c: Client, collection: str , p: SearchParams, err &: Error): str Searches a collection and returns the answer as JSON.
The example for this item is shown with the ones above: db-typesense-Search.salam
func Search (c: Client, collection: str , p: SearchParams, err &: Error): SearchResult The example for this item is shown with the ones above: db-typesense-Search.salam
func MultiSearchRaw (c: Client, searches: Vector <SearchRequest>, common: SearchParams, err &: Error): str Runs several searches in one request and returns the answer as JSON.
The example for this item is shown with the ones above: db-typesense-Search.salam
func MultiSearch (c: Client, searches: Vector <SearchRequest>, common: SearchParams, err &: Error): Vector <SearchResult> Runs several searches in one request; the common parameters apply to all of them, and each result has its own code and error.
The example for this item is shown with the ones above: db-typesense-Search.salam
func UnionSearch (c: Client, searches: Vector <SearchRequest>, common: SearchParams, err &: Error): SearchResult Runs several searches and merges their hits into one ranked list.
The example for this item is shown with the ones above: db-typesense-Search.salam
func HitsAs <T>(r: SearchResult, out &: Vector <T>, err &: Error): bool Reads the hit documents into a list of your structs.
The example for this item is shown with the ones above: db-typesense-Search.salam
func Highlight (h: Hit, field: str ): str The highlighted snippet of a field in a hit; snippets of a list field are joined with spaces.
The example for this item is shown with the ones above: db-typesense-Search.salam
func FreeResult (r &: SearchResult) Releases the lists a search result holds.
The example for this item is shown with the ones above: db-typesense-Search.salam
func SynonymJSON (s: Synonym): str The JSON body of a synonym.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func CurationJSON (r: CurationRule): str The JSON body of a curation rule.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertSynonymSet (c: Client, name: str , items: Vector <Synonym>, err &: Error): SynonymSet Creates or replaces a synonym set (Typesense 30).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetSynonymSet (c: Client, name: str , err &: Error): SynonymSet The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ListSynonymSets (c: Client, err &: Error): Vector <SynonymSet> The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func DeleteSynonymSet (c: Client, name: str , err &: Error): str Deletes a synonym set and returns its name.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertSynonymItem (c: Client, set: str , item: Synonym, err &: Error): Synonym Adds or replaces one synonym in a set that exists.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetSynonymItem (c: Client, set: str , id: str , err &: Error): Synonym The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ListSynonymItems (c: Client, set: str , err &: Error): Vector <Synonym> The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func DeleteSynonymItem (c: Client, set: str , id: str , err &: Error): str Deletes one synonym of a set and returns its id.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertSynonym (c: Client, collection: str , s: Synonym, err &: Error): Synonym Adds or replaces a synonym of one collection (Typesense 29 and older).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetSynonym (c: Client, collection: str , id: str , err &: Error): Synonym One synonym of a collection (Typesense 29 and older).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ListSynonyms (c: Client, collection: str , err &: Error): Vector <Synonym> The synonyms of a collection (Typesense 29 and older).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func DeleteSynonym (c: Client, collection: str , id: str , err &: Error): str Deletes a synonym of a collection (Typesense 29 and older).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertCurationSet (c: Client, name: str , items: Vector <CurationRule>, err &: Error): CurationSet Creates or replaces a curation set (Typesense 30).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetCurationSet (c: Client, name: str , err &: Error): CurationSet The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ListCurationSets (c: Client, err &: Error): Vector <CurationSet> The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func DeleteCurationSet (c: Client, name: str , err &: Error): str Deletes a curation set and returns its name.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertCurationItem (c: Client, set: str , r: CurationRule, err &: Error): CurationRule Adds or replaces one rule in a curation set that exists.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetCurationItem (c: Client, set: str , id: str , err &: Error): CurationRule One rule of a curation set.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ListCurationItems (c: Client, set: str , err &: Error): Vector <CurationRule> The rules of a curation set.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func DeleteCurationItem (c: Client, set: str , id: str , err &: Error): str Deletes one rule of a curation set and returns its id.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertOverride (c: Client, collection: str , r: CurationRule, err &: Error): CurationRule Adds or replaces an override of one collection (Typesense 29 and older).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetOverride (c: Client, collection: str , id: str , err &: Error): CurationRule One override of a collection (Typesense 29 and older).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ListOverrides (c: Client, collection: str , err &: Error): Vector <CurationRule> The overrides of a collection (Typesense 29 and older).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func DeleteOverride (c: Client, collection: str , id: str , err &: Error): str Deletes an override of a collection (Typesense 29 and older).
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertPreset (c: Client, name: str , value: str , err &: Error): Preset Creates or replaces a preset; pass its value as JSON.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertSearchPreset (c: Client, name: str , p: SearchParams, err &: Error): Preset Saves a SearchParams as a preset.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetPreset (c: Client, name: str , err &: Error): Preset The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ListPresets (c: Client, err &: Error): Vector <Preset> The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func DeletePreset (c: Client, name: str , err &: Error): str Deletes a preset and returns its name.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func UpsertStopwords (c: Client, id: str , words: Vector < str >, locale: str , err &: Error): Stopwords Creates or replaces a stopword set.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetStopwords (c: Client, id: str , err &: Error): Stopwords The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ListStopwords (c: Client, err &: Error): Vector <Stopwords> The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func DeleteStopwords (c: Client, id: str , err &: Error): str Deletes a stopword set and returns its id.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func ImportStemmingJSONL (c: Client, id: str , jsonl: str , err &: Error): bool Imports a stemming dictionary written one {"word","root"} object per line.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
ImportStemmingDictionary #
func ImportStemmingDictionary (c: Client, id: str , words: Vector <StemWord>, err &: Error): bool Imports a stemming dictionary from a list of words.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func GetStemmingDictionary (c: Client, id: str , err &: Error): StemmingDictionary The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
ListStemmingDictionaries #
func ListStemmingDictionaries (c: Client, err &: Error): Vector < str > The ids of every stemming dictionary.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
DeleteStemmingDictionary #
func DeleteStemmingDictionary (c: Client, id: str , err &: Error): str Deletes a stemming dictionary and returns its id.
The example for this item is shown with the ones above: db-typesense-UpsertSynonymSet.salam
func IndexDocument (c: Client, collection: str , document: str , opts: WriteOptions, err &: Error): str Writes one document with the given options.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func CreateDocument (c: Client, collection: str , document: str , err &: Error): str Indexes a new document and returns it.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func UpsertDocument (c: Client, collection: str , document: str , err &: Error): str Creates a document or replaces the one with the same id.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func EmplaceDocument (c: Client, collection: str , document: str , err &: Error): str Creates a document or updates the given fields of the one with the same id.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func UpdateDocument (c: Client, collection: str , id: str , partial: str , err &: Error): str Changes some fields of a document.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func UpdateDocumentWith (c: Client, collection: str , id: str , partial: str , dirty_values: str , err &: Error): str UpdateDocument with a dirty_values mode.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func GetDocument (c: Client, collection: str , id: str , err &: Error): str One document, by id, as JSON.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func DocumentExists (c: Client, collection: str , id: str , err &: Error): bool Whether a document with this id exists.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func DeleteDocument (c: Client, collection: str , id: str , err &: Error): str Deletes a document and returns it.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func DeleteByFilter (c: Client, collection: str , filter_by: str , batch_size: int , err &: Error): i64 Deletes every document that matches a filter and returns how many; 0 for the batch size means the server default.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func UpdateByFilter (c: Client, collection: str , filter_by: str , partial: str , err &: Error): i64 Changes the given fields of every document that matches a filter and returns how many.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func ImportJSONL (c: Client, collection: str , jsonl: str , opts: WriteOptions, err &: Error): ImportResult Imports documents written one JSON object per line.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func ImportDocuments (c: Client, collection: str , documents: Vector < str >, opts: WriteOptions, err &: Error): ImportResult Imports a list of JSON documents; each one is put on a single line first.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func ImportOf <T>(c: Client, collection: str , documents: Vector <T>, opts: WriteOptions, err &: Error): ImportResult Imports a list of your own structs, written with json.Marshal.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func CreateDocumentOf <T>(c: Client, collection: str , document: T, err &: Error): str Creates one document from your own struct.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func UpsertDocumentOf <T>(c: Client, collection: str , document: T, err &: Error): str Upserts one document from your own struct.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func DecodeDocument <T>(document: str , out &: T, err &: Error): bool Reads one JSON document into your struct.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func GetDocumentAs <T>(c: Client, collection: str , id: str , out &: T, err &: Error): bool Reads one document by id into your struct.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func DecodeDocuments <T>(documents: Vector < str >, out &: Vector <T>, err &: Error): bool Reads a list of JSON documents into a list of your structs.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func ExportJSONL (c: Client, collection: str , opts: ExportOptions, err &: Error): str Exports documents, one JSON object per line.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func ExportDocuments (c: Client, collection: str , opts: ExportOptions, err &: Error): Vector < str > Exports documents as a list, one JSON document each.
The example for this item is shown with the ones above: db-typesense-ImportDocuments.salam
func New (url: str , api_key: str ): Client A client for one node. A URL with no scheme gets http://, and a trailing slash is dropped.
The example for this item is shown with the ones above: db-typesense-Client.salam
func NewCluster (urls: Vector < str >, api_key: str ): Client A client for several nodes, tried in turn.
The example for this item is shown with the ones above: db-typesense-Client.salam
func SetNearestNode (c &: Client, url: str ) Sets the node to try first.
The example for this item is shown with the ones above: db-typesense-Client.salam
func AddNode (c &: Client, url: str ) Adds one more node to a client.
The example for this item is shown with the ones above: db-typesense-Client.salam
func AddHeader (c &: Client, name: str , value: str ) Adds a header to every request this client sends.
The example for this item is shown with the ones above: db-typesense-Client.salam
Releases the memory a client holds.
The example for this item is shown with the ones above: db-typesense-Client.salam
func NodeHealthy (c: Client, index: int ): bool Whether the node at this index may be tried now; -1 asks about the nearest node.
The example for this item is shown with the ones above: db-typesense-Client.salam
func Ok (err: Error): bool True when the last call worked.
The example for this item is shown with the ones above: db-typesense-Client.salam
func IsNotFound (err: Error): bool True when the server answered 404.
The example for this item is shown with the ones above: db-typesense-Client.salam
func IsConflict (err: Error): bool True when the server answered 409, for example when a collection or document already exists.
The example for this item is shown with the ones above: db-typesense-Client.salam
func ErrorString (err: Error): str The error as one line of text, or empty when there is none.
The example for this item is shown with the ones above: db-typesense-Client.salam
func Request (c: Client, method: str , path: str , body: str , err &: Error): str Sends any request with a JSON body and returns the response body; for routes this package has no function for.
The example for this item is shown with the ones above: db-typesense-Client.salam
func RequestAs (c: Client, method: str , path: str , content_type: str , body: str , err &: Error): str Like Request, with a content type of your choice.
The example for this item is shown with the ones above: db-typesense-Client.salam
func Health (c: Client, err &: Error): bool True when the node is ready to serve.
The example for this item is shown with the ones above: db-typesense-Client.salam
func IsHealthy (c: Client): bool Health without the error argument.
The example for this item is shown with the ones above: db-typesense-Client.salam
func Debug (c: Client, err &: Error): str The /debug answer, with the server version, as JSON.
The example for this item is shown with the ones above: db-typesense-Client.salam
func ServerVersion (c: Client, err &: Error): str The version of the server, such as 30.2.
The example for this item is shown with the ones above: db-typesense-Client.salam
func Stats (c: Client, err &: Error): str Request rates and latencies, as JSON.
The example for this item is shown with the ones above: db-typesense-Client.salam
func Metrics (c: Client, err &: Error): str Memory, disk and CPU numbers, as JSON.
The example for this item is shown with the ones above: db-typesense-Client.salam
func Status (c: Client, err &: Error): ClusterStatus The raft state of the node.
The example for this item is shown with the ones above: db-typesense-Client.salam
func CreateSnapshot (c: Client, snapshot_path: str , err &: Error): bool Writes a snapshot of the data to a directory on the server, for backups.
The example for this item is shown with the ones above: db-typesense-Client.salam
func Vote (c: Client, err &: Error): bool Asks the node to start a leader election; true when it did.
The example for this item is shown with the ones above: db-typesense-Client.salam
func ClearCache (c: Client, err &: Error): bool Empties the search result cache.
The example for this item is shown with the ones above: db-typesense-Client.salam
func CompactDB (c: Client, err &: Error): bool Compacts the on disk database.
The example for this item is shown with the ones above: db-typesense-Client.salam
func ResetPeers (c: Client, err &: Error): bool Resets the raft peers of a node that lost its quorum.
The example for this item is shown with the ones above: db-typesense-Client.salam
func SchemaChanges (c: Client, err &: Error): Vector < str > Schema changes still running, one JSON object each.
The example for this item is shown with the ones above: db-typesense-Client.salam
func UpdateConfig (c: Client, config: str , err &: Error): bool Changes server settings at run time; pass them as JSON.
The example for this item is shown with the ones above: db-typesense-Client.salam
func SetSlowRequestLog (c: Client, millis: int , err &: Error): bool Logs requests slower than this many milliseconds; -1 turns the log off.
The example for this item is shown with the ones above: db-typesense-Client.salam