Standard library · Database

db/meilisearch

A Meilisearch client: indexes, documents, full text, faceted, hybrid and federated search, settings, tasks and API keys.

import db.meilisearch

Meilisearch is a fast search engine with typo tolerance, filters, facets and AI powered hybrid search. This package speaks its HTTP API directly with net.http and covers all of it: indexes, documents in JSON, NDJSON or CSV, every search parameter, multi-search and federated search, facet search, similar documents, every index setting, tasks and batches, API keys and tenant tokens. The examples need a running server, so they are only checked.

Every call takes an Error as its last argument and fills it when something fails; check it with Ok. Writes do not happen at once: they return a TaskInfo and Meilisearch applies them in order, so call Wait when the next step needs the change. Search hits and documents come back as raw JSON text; read them into your own structs with HitsAs and GetDocumentAs. For a route with no function of its own, use Request.

Types

SearchRequest

struct SearchRequest
Everything a search can ask for. Only fields you set are sent: empty text and lists, -1 numbers and false flags are left out.
NameTypeDescription
querystr = ""The words to search for; empty lists every document.
offsetint = -1How many hits to skip.
limitint = -1How many hits to return; 20 by default.
pageint = -1The page number, for numbered pages with an exact total.
hits_per_pageint = -1The hits on each numbered page.
filterstr = ""A filter expression such as year > 2000 AND genre = Drama, or a JSON array of them.
facetsVectorCount the values of these fields among the hits.
attributes_to_retrieveVectorReturn only these fields.
attributes_to_cropVectorCut these fields around the matched words.
crop_lengthint = -1How many words a cropped field keeps.
crop_markerstr = ""The text that marks a cut.
attributes_to_highlightVectorWrap the matched words of these fields in tags.
highlight_pre_tagstr = ""The tag before a match; <em> by default.
highlight_post_tagstr = ""The tag after a match.
show_matches_positionbool = falseReturn where every match is.
sortVectorSort rules such as year:desc.
matching_strategystr = ""One of the MATCH_ values.
show_ranking_scorebool = falseReturn the relevancy score of each hit.
show_ranking_score_detailsbool = falseReturn how the score was built.
ranking_score_thresholdf64 = -1Drop hits scoring below this, from 0 to 1.
attributes_to_search_onVectorSearch only these fields.
distinctstr = ""Return at most one hit for each value of this field.
localesVectorThe languages of the query, such as fas.
vectorVectorSearch by this vector.
hybrid_embedderstr = ""The embedder for AI powered search; setting it turns hybrid search on.
hybrid_semantic_ratiof64 = -1How much meaning outweighs keywords, from 0 to 1.
retrieve_vectorsbool = falseAlso return the stored vectors.
mediastr = ""Raw JSON media for multimodal search, such as an image.
extrastr = ""A raw JSON object whose fields are added to the request, for parameters this struct does not have yet.
db-meilisearch-Search.salam
import db.meilisearch

struct Movie:
    pub id: int = 0
    pub title: str = ""
end

func main:
    c := meilisearch.New("http://127.0.0.1:7700", "searchKey")
    mut err := meilisearch.Error {}

    quick := meilisearch.Query(c, "movies", "botman", err)
    println quick.query, quick.estimated_total_hits, quick.processing_time_ms

    mut r := meilisearch.SearchRequest { query = "space", limit = 10, offset = 0, filter = "year > 2000 AND genre = Drama" }
    r.facets.push("genre")
    r.sort.push("year:desc")
    r.attributes_to_retrieve.push("id")
    r.attributes_to_retrieve.push("title")
    r.attributes_to_highlight.push("title")
    r.highlight_pre_tag = "<mark>"
    r.highlight_post_tag = "</mark>"
    r.attributes_to_crop.push("overview")
    r.crop_length = 20
    r.crop_marker = "..."
    r.matching_strategy = meilisearch.MATCH_ALL
    r.show_ranking_score = true
    r.show_ranking_score_details = false
    r.show_matches_position = false
    r.ranking_score_threshold = 0.2
    r.attributes_to_search_on.push("title")
    r.locales.push("eng")
    r.distinct = "studio"
    res := meilisearch.Search(c, "movies", r, err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        ret
    end
    println res.index_uid, res.offset, res.limit, res.facet_distribution, res.facet_stats, res.raw.len()
    each hit in res.hits:
        println hit
    end
    mut movies := Vector {} as Vector<Movie>
    if meilisearch.HitsAs(res, movies, err):
        println movies.len()
    end

    pages := meilisearch.Search(c, "movies", meilisearch.SearchRequest { query = "space", page = 2, hits_per_page = 20 }, err)
    println pages.page, pages.hits_per_page, pages.total_hits, pages.total_pages

    mut hybrid := meilisearch.SearchRequest { query = "a sad robot", hybrid_embedder = "default", hybrid_semantic_ratio = 0.7, retrieve_vectors = false, matching_strategy = meilisearch.MATCH_LAST }
    hybrid.vector.push(0.1)
    hybrid.media = `{"image": "https://example.com/robot.png"}`
    hybrid.extra = `{"showPerformanceDetails": true}`
    println meilisearch.Search(c, "movies", hybrid, err).semantic_hit_count, meilisearch.MATCH_FREQUENCY

    mut queries := Vector {} as Vector<meilisearch.MultiQuery>
    queries.push(meilisearch.MultiQuery { index_uid = "movies", request = meilisearch.SearchRequest { query = "moana" } })
    queries.push(meilisearch.MultiQuery { index_uid = "books", request = meilisearch.SearchRequest { query = "moana" }, weight = 0.5, remote = "" })
    each one in meilisearch.MultiSearch(c, queries, err):
        println one.index_uid, one.hits.len()
    end
    fed := meilisearch.FederatedSearch(c, queries, meilisearch.Federation { offset = 0, limit = 20, page = -1, hits_per_page = -1, facets_by_index = `{"movies": ["genre"]}`, merge_facets = `{}` }, err)
    println fed.hits.len()

    mut fr := meilisearch.FacetSearchRequest { facet_name = "genre", facet_query = "dra", query = "space", filter = "year > 2000", matching_strategy = meilisearch.MATCH_ALL, exhaustive_facet_count = true }
    fr.attributes_to_search_on.push("title")
    fs := meilisearch.FacetSearch(c, "movies", fr, err)
    println fs.facet_query, fs.processing_time_ms
    each h in fs.hits:
        println h.value, h.count
    end

    mut sr := meilisearch.SimilarRequest { id = "143", embedder = "default", limit = 5, offset = 0, filter = "year > 2000", show_ranking_score = true, show_ranking_score_details = false, ranking_score_threshold = 0.5, retrieve_vectors = false }
    sr.attributes_to_retrieve.push("title")
    println meilisearch.SimilarDocuments(c, "movies", sr, err).hits.len()
end

SearchResult

struct SearchResult
The answer to a search. Numbers the server did not send are -1.
NameTypeDescription
index_uidstr = ""The index, in multi-search results.
hitsVectorEach hit as its own JSON text; read them into structs with HitsAs.
querystr = ""The query that was run.
processing_time_msi64 = 0How long the search took, in milliseconds.
offseti64 = -1How many hits were skipped.
limiti64 = -1The page size.
estimated_total_hitsi64 = -1About how many documents match.
pagei64 = -1The page number, with numbered pages.
hits_per_pagei64 = -1The hits on each page.
total_hitsi64 = -1Exactly how many documents match, with numbered pages.
total_pagesi64 = -1How many pages there are.
facet_distributionstr = ""The value counts of the requested facets, as raw JSON.
facet_statsstr = ""The minimum and maximum of numeric facets, as raw JSON.
semantic_hit_counti64 = -1How many hits came from meaning rather than keywords.
rawstr = ""The whole response body.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

MultiQuery

struct MultiQuery
One search inside a multi-search.
NameTypeDescription
index_uidstr = ""The index to search.
requestSearchRequestThe search itself.
weightf64 = -1In a federated search, how much this query counts; -1 leaves it out.
remotestr = ""In a federated search across instances, the remote to ask.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

Federation

struct Federation
How a federated search merges its queries into one list.
NameTypeDescription
offsetint = -1How many merged hits to skip.
limitint = -1How many merged hits to return.
pageint = -1The page number.
hits_per_pageint = -1The hits on each page.
facets_by_indexstr = ""Facets to count for each index, as raw JSON.
merge_facetsstr = ""How to merge those facets, as raw JSON.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

FacetSearchRequest

struct FacetSearchRequest
A search among the values of one facet.
NameTypeDescription
facet_namestr = ""The facet field.
facet_querystr = ""The text the values should start with.
querystr = ""Count only documents matching this search.
filterstr = ""Count only documents matching this filter.
matching_strategystr = ""One of the MATCH_ values.
attributes_to_search_onVectorSearch only these fields.
exhaustive_facet_countbool = falseCount exactly, which is slower.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

FacetHit

struct FacetHit
One facet value.
NameTypeDescription
valuestr = ""The value.
counti64 = 0How many documents have it.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

FacetSearchResult

struct FacetSearchResult
The answer to a facet search.
NameTypeDescription
hitsVectorThe matching values.
facet_querystr = ""The facet query that was run.
processing_time_msi64 = 0How long it took, in milliseconds.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

SimilarRequest

struct SimilarRequest
Documents that resemble one document, by its vectors.
NameTypeDescription
idstr = ""The document to compare with.
embedderstr = ""The embedder whose vectors are compared.
offsetint = -1How many hits to skip.
limitint = -1How many hits to return.
filterstr = ""Only documents matching this filter.
attributes_to_retrieveVectorReturn only these fields.
show_ranking_scorebool = falseReturn the similarity score.
show_ranking_score_detailsbool = falseReturn how the score was built.
ranking_score_thresholdf64 = -1Drop hits scoring below this.
retrieve_vectorsbool = falseAlso return the stored vectors.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

Version

struct Version
The server version.
NameTypeDescription
pkg_versionstr = ""The version, such as 1.15.2.
commit_shastr = ""The commit the server was built from.
commit_datestr = ""The date of that commit.
db-meilisearch-Client.salam
import db.meilisearch

func main:
    c := meilisearch.WithAgent(meilisearch.New("http://127.0.0.1:7700", "masterKey"), "my-app/1.0")
    mut err := meilisearch.Error {}
    if not meilisearch.IsHealthy(c):
        println "Meilisearch is not reachable at " + c.host
        ret
    end
    println meilisearch.Health(c, err), meilisearch.VERSION

    v := meilisearch.GetVersion(c, err)
    println v.pkg_version, v.commit_sha, v.commit_date
    st := meilisearch.GetStats(c, err)
    println st.database_size, st.used_database_size, st.last_update, st.indexes

    dump := meilisearch.CreateDump(c, err)
    println dump.task_uid, meilisearch.CreateSnapshot(c, err).status
    println meilisearch.GetExperimentalFeatures(c, err)
    println meilisearch.UpdateExperimentalFeatures(c, `{"metrics": true}`, err)
    println meilisearch.GetMetrics(c, err).len()
    println meilisearch.GetNetwork(c, err)
    println meilisearch.UpdateNetwork(c, `{"self": "ms-0"}`, err)
    println meilisearch.Export(c, `{"url": "http://backup:7700", "apiKey": "key"}`, err).kind

    body := meilisearch.Request(c, "GET", "/indexes?limit=1", "", err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        println err.status, err.code, err.kind, err.message, err.link
        ret
    end
    println body
    println meilisearch.RequestAs(c, "POST", "/indexes/movies/documents", "application/x-ndjson", "{\"id\": 1}\n", err)
    p := meilisearch.Page {}
    println p.results.len(), p.offset, p.limit, p.total, p.from, p.next, c.api_key.len() > 0, c.agent
end

Stats

struct Stats
Statistics of the whole instance.
NameTypeDescription
database_sizei64 = 0The database size on disk, in bytes.
used_database_sizei64 = 0The bytes actually in use.
last_updatestr = ""When anything last changed.
indexesstr = ""The statistics of every index, as raw JSON.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

Client

struct Client
Where the server is and which key to use. A plain value; make one with New and share it freely.
NameTypeDescription
hoststr = ""The server address, such as http://127.0.0.1:7700, with no trailing slash.
api_keystr = ""The API key sent as Authorization: Bearer; empty sends no header.
agentstr = ""Extra text added to the client header, such as your app name.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

Error

struct Error
What went wrong. An empty code means the call worked; every function clears it before it starts.
NameTypeDescription
statusint = 0The HTTP status; 0 when the server could not be reached or the error happened in the client.
codestr = ""The Meilisearch error code, such as index_not_found, or communication_error, timeout and decode_error from the client.
kindstr = ""The error type: invalid_request, auth, internal and so on.
messagestr = ""The human readable message.
linkstr = ""A link to the page of the Meilisearch documentation about this error.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

Page

struct Page
One page of raw JSON documents, from GetDocuments.
NameTypeDescription
resultsVectorEach document as its own JSON text.
offseti64 = 0How many documents were skipped.
limiti64 = 0The page size.
totali64 = 0How many documents match in total.
fromi64 = -1Unused for documents; -1.
nexti64 = -1Unused for documents; -1.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

TaskInfo

struct TaskInfo
The receipt of a change. Meilisearch applies every write later, in order; wait for it with Wait.
NameTypeDescription
task_uidi64 = -1The task number; -1 when the call failed.
index_uidstr = ""The index it changes, if any.
statusstr = ""The status when it was queued.
kindstr = ""The task type, such as documentAdditionOrUpdate.
enqueued_atstr = ""When it was queued.
db-meilisearch-GetTasks.salam
import db.meilisearch

func main:
    c := meilisearch.New("http://127.0.0.1:7700", "masterKey")
    mut err := meilisearch.Error {}

    info := meilisearch.DeleteIndex(c, "old_movies", err)
    t := meilisearch.WaitForTask(c, info.task_uid, 30000, 100, err)
    println t.uid, t.batch_uid, t.index_uid, t.status, t.kind, t.canceled_by, t.details, t.duration
    println t.enqueued_at, t.started_at, t.finished_at
    if t.status == meilisearch.STATUS_FAILED:
        println t.error.code, t.error.message
    end
    println meilisearch.GetTask(c, info.task_uid, err).status

    mut q := meilisearch.TaskQuery { limit = 20, from = -1, reverse = true, after_enqueued_at = "2025-01-01T00:00:00Z" }
    q.statuses.push(meilisearch.STATUS_SUCCEEDED)
    q.statuses.push(meilisearch.STATUS_FAILED)
    q.index_uids.push("movies")
    q.types.push("documentAdditionOrUpdate")
    q.uids.push(1)
    q.batch_uids.push(1)
    q.canceled_by.push(2)
    q.before_enqueued_at = "2030-01-01T00:00:00Z"
    q.before_started_at = "2030-01-01T00:00:00Z"
    q.after_started_at = "2025-01-01T00:00:00Z"
    q.before_finished_at = "2030-01-01T00:00:00Z"
    q.after_finished_at = "2025-01-01T00:00:00Z"
    page := meilisearch.GetTasks(c, q, err)
    println page.total, page.limit, page.from, page.next
    each task in page.results:
        println task.uid, task.kind, task.status
    end

    mut pending := meilisearch.TaskQuery {}
    pending.statuses.push(meilisearch.STATUS_ENQUEUED)
    pending.statuses.push(meilisearch.STATUS_PROCESSING)
    println meilisearch.CancelTasks(c, pending, err).task_uid
    mut finished := meilisearch.TaskQuery {}
    finished.statuses.push(meilisearch.STATUS_CANCELED)
    println meilisearch.DeleteTasks(c, finished, err).task_uid

    batches := meilisearch.GetBatches(c, meilisearch.TaskQuery { limit = 5 }, err)
    println batches.total, batches.limit, batches.from, batches.next
    each b in batches.results:
        one := meilisearch.GetBatch(c, b.uid, err)
        println one.uid, one.details, one.stats, one.progress, one.duration, one.started_at, one.finished_at
    end
end

Task

struct Task
A task with its result.
NameTypeDescription
uidi64 = -1The task number.
batch_uidi64 = -1The batch it ran in; -1 before it runs.
index_uidstr = ""The index it changes.
statusstr = ""One of the STATUS_ values.
kindstr = ""The task type.
canceled_byi64 = -1The task that canceled it; -1 if none.
detailsstr = ""Details that depend on the type, as raw JSON.
errorErrorWhy it failed.
durationstr = ""How long it ran, as an ISO 8601 duration.
enqueued_atstr = ""When it was queued.
started_atstr = ""When it started.
finished_atstr = ""When it finished.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

TaskQuery

struct TaskQuery
Which tasks to list, cancel or delete. Empty fields are left out.
NameTypeDescription
uidsVectorOnly these tasks.
batch_uidsVectorOnly tasks of these batches.
canceled_byVectorOnly tasks canceled by these tasks.
statusesVectorOnly these statuses.
typesVectorOnly these task types.
index_uidsVectorOnly tasks of these indexes.
limitint = 0The page size; 0 for the default. Listing only.
fromi64 = -1Start from this task number; -1 for the newest. Listing only.
reversebool = falseOldest first. Listing only.
before_enqueued_atstr = ""Queued before this date.
after_enqueued_atstr = ""Queued after this date.
before_started_atstr = ""Started before this date.
after_started_atstr = ""Started after this date.
before_finished_atstr = ""Finished before this date.
after_finished_atstr = ""Finished after this date.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

TaskPage

struct TaskPage
One page of tasks.
NameTypeDescription
resultsVectorThe tasks, newest first.
limiti64 = 0The page size.
fromi64 = -1The first task number on this page.
nexti64 = -1Pass this as from for the next page; -1 on the last page.
totali64 = 0How many tasks match.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

Batch

struct Batch
A batch: tasks that Meilisearch ran together.
NameTypeDescription
uidi64 = -1The batch number.
detailsstr = ""Details of its tasks, as raw JSON.
statsstr = ""Counts by status, type and index, as raw JSON.
progressstr = ""Progress while it runs, as raw JSON; empty when done.
durationstr = ""How long it ran.
started_atstr = ""When it started.
finished_atstr = ""When it finished.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

BatchPage

struct BatchPage
One page of batches.
NameTypeDescription
resultsVectorThe batches.
limiti64 = 0The page size.
fromi64 = -1The first batch number on this page.
nexti64 = -1Pass this as from for the next page; -1 on the last page.
totali64 = 0How many batches match.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

Key

struct Key
An API key.
NameTypeDescription
uidstr = ""The key id, a UUID.
keystr = ""The secret key value to send.
namestr = ""Its name.
descriptionstr = ""Its description.
actionsVectorWhat it may do, such as search or * for everything.
indexesVectorWhich indexes it may use; * for all.
expires_atstr = ""When it stops working; empty for never.
created_atstr = ""When it was made.
updated_atstr = ""When it last changed.
db-meilisearch-CreateKey.salam
import db.meilisearch
import time

func main:
    admin := meilisearch.New("http://127.0.0.1:7700", "masterKey")
    mut err := meilisearch.Error {}

    mut r := meilisearch.KeyRequest { name = "Front end search", description = "Used by the web app", expires_at = "2030-01-01T00:00:00Z", uid = "" }
    r.actions.push("search")
    r.indexes.push("movies")
    k := meilisearch.CreateKey(admin, r, err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        ret
    end
    println k.uid, k.key, k.name, k.description, k.expires_at, k.created_at, k.updated_at
    println k.actions.len(), k.indexes.len()

    println meilisearch.GetKey(admin, k.uid, err).name
    page := meilisearch.GetKeys(admin, 0, 20, err)
    println page.total, page.offset, page.limit
    each one in page.results:
        println one.name
    end
    println meilisearch.UpdateKey(admin, k.uid, "Web search", "Search only, movies only", err).name

    rules := `{"movies": {"filter": "user_id = 42"}}`
    token := meilisearch.TenantToken(k.uid, k.key, rules, time.Now() + 3600, err)
    user := meilisearch.New("http://127.0.0.1:7700", token)
    println meilisearch.Query(user, "movies", "", err).hits.len()

    println meilisearch.DeleteKey(admin, k.uid, err)
end

KeyRequest

struct KeyRequest
A new API key.
NameTypeDescription
uidstr = ""A UUID to use as its id; empty lets the server pick one.
namestr = ""Its name.
descriptionstr = ""Its description.
actionsVectorWhat it may do.
indexesVectorWhich indexes it may use.
expires_atstr = ""An RFC 3339 date when it stops working; empty for never.

The example for this item is shown with the ones above: db-meilisearch-CreateKey.salam

KeyPage

struct KeyPage
One page of keys.
NameTypeDescription
resultsVectorThe keys.
offseti64 = 0How many were skipped.
limiti64 = 0The page size.
totali64 = 0How many keys there are.

The example for this item is shown with the ones above: db-meilisearch-CreateKey.salam

Index

struct Index
An index: a named collection of documents.
NameTypeDescription
uidstr = ""The index name.
primary_keystr = ""The field that identifies a document; empty until it is known.
created_atstr = ""When the index was made.
updated_atstr = ""When it last changed.
db-meilisearch-CreateIndex.salam
import db.meilisearch

func main:
    c := meilisearch.New("http://127.0.0.1:7700", "masterKey")
    mut err := meilisearch.Error {}

    info := meilisearch.CreateIndex(c, "movies", "id", err)
    println info.task_uid, info.index_uid, info.status, info.kind, info.enqueued_at
    done := meilisearch.Wait(c, info, err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        ret
    end
    println done.status

    i := meilisearch.GetIndex(c, "movies", err)
    println i.uid, i.primary_key, i.created_at, i.updated_at
    page := meilisearch.ListIndexes(c, 0, 20, err)
    println page.total, page.offset, page.limit
    each idx in page.results:
        println idx.uid
    end

    meilisearch.WaitForTask(c, meilisearch.UpdateIndex(c, "movies", "movie_id", err).task_uid, 10000, 50, err)
    meilisearch.Wait(c, meilisearch.RenameIndex(c, "movies", "films", err), err)

    mut swaps := Vector {} as Vector<meilisearch.IndexSwap>
    swaps.push(meilisearch.IndexSwap { first = "films", second = "films_next" })
    swaps.push(meilisearch.IndexSwap { first = "drafts", second = "drafts_v2", rename = true })
    meilisearch.Wait(c, meilisearch.SwapIndexes(c, swaps, err), err)

    s := meilisearch.GetIndexStats(c, "films", err)
    println s.number_of_documents, s.raw_document_db_size, s.avg_document_size, s.is_indexing
    println s.number_of_embeddings, s.number_of_embedded_documents, s.field_distribution
    meilisearch.Wait(c, meilisearch.DeleteIndex(c, "films", err), err)
end

IndexPage

struct IndexPage
One page of indexes.
NameTypeDescription
resultsVectorThe indexes on this page.
offseti64 = 0How many were skipped.
limiti64 = 0The page size.
totali64 = 0How many indexes there are.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

IndexStats

struct IndexStats
Statistics of one index.
NameTypeDescription
number_of_documentsi64 = 0How many documents it holds.
raw_document_db_sizei64 = 0The size of the stored documents, in bytes.
avg_document_sizei64 = 0The average document size, in bytes.
is_indexingbool = falseA task is changing it right now.
number_of_embeddingsi64 = 0How many vectors it holds.
number_of_embedded_documentsi64 = 0How many documents have at least one vector.
field_distributionstr = ""How many documents have each field, as raw JSON.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

IndexSwap

struct IndexSwap
Two indexes for SwapIndexes.
NameTypeDescription
firststr = ""The first index.
secondstr = ""The second index.
renamebool = falseRename first to second instead of swapping, when second does not exist.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

DocumentsQuery

struct DocumentsQuery
Which documents GetDocuments returns. Zero values and empty lists are left out.
NameTypeDescription
offsetint = 0How many to skip.
limitint = 0How many to return.
fieldsVectorReturn only these fields.
filterstr = ""A filter expression, or a JSON array of them; the fields must be filterable.
idsVectorReturn only these documents.
sortVectorSort rules such as year:desc; the fields must be sortable.
retrieve_vectorsbool = falseAlso return the stored vectors.
db-meilisearch-AddDocuments.salam
import db.meilisearch

struct Movie:
    pub id: int = 0
    pub title: str = ""
    pub year: int = 0
end

func main:
    c := meilisearch.New("http://127.0.0.1:7700", "masterKey")
    mut err := meilisearch.Error {}

    docs := `[{"id": 1, "title": "Carol", "year": 2015}, {"id": 2, "title": "Moana", "year": 2016}]`
    meilisearch.Wait(c, meilisearch.AddDocuments(c, "movies", docs, "id", err), err)
    meilisearch.Wait(c, meilisearch.UpdateDocuments(c, "movies", `[{"id": 2, "year": 2017}]`, "", err), err)
    meilisearch.Wait(c, meilisearch.AddDocumentsNdjson(c, "movies", "{\"id\": 3, \"title\": \"Heat\"}\n", "", err), err)
    meilisearch.Wait(c, meilisearch.UpdateDocumentsNdjson(c, "movies", "{\"id\": 3, \"year\": 1995}\n", "", err), err)
    meilisearch.Wait(c, meilisearch.AddDocumentsCsv(c, "movies", "id:number;title\n4;Up\n", "", ";", err), err)
    meilisearch.Wait(c, meilisearch.UpdateDocumentsCsv(c, "movies", "id:number,year:number\n4,2009\n", "", "", err), err)

    mut typed := Vector {} as Vector<Movie>
    typed.push(Movie { id = 5, title = "Alien", year = 1979 })
    meilisearch.Wait(c, meilisearch.AddDocumentsOf(c, "movies", typed, "id", err), err)

    mut many := Vector {} as Vector<str>
    repeat 2500 in i:
        many.push(`{"id": ` + (100 + i) + `, "title": "Movie ` + i + `"}`)
    end
    tasks := meilisearch.AddDocumentsInBatches(c, "movies", many, 1000, "id", err)
    each t in tasks:
        meilisearch.Wait(c, t, err)
    end

    mut fields := Vector {} as Vector<str>
    fields.push("title")
    println meilisearch.GetDocument(c, "movies", "1", fields, err)
    mut m := Movie {}
    if meilisearch.GetDocumentAs(c, "movies", "2", m, err):
        println m.title, m.year
    end

    mut q := meilisearch.DocumentsQuery { limit = 10, filter = "year > 2000", retrieve_vectors = false }
    q.fields.push("id")
    q.fields.push("title")
    q.sort.push("year:desc")
    q.ids.push("1")
    q.ids.push("2")
    page := meilisearch.GetDocuments(c, "movies", meilisearch.DocumentsQuery { offset = 0, limit = 20 }, err)
    mut movies := Vector {} as Vector<Movie>
    if meilisearch.DocumentsAs(page, movies, err):
        println movies.len(), page.total
    end
    println meilisearch.GetDocuments(c, "movies", q, err).results.len()

    meilisearch.Wait(c, meilisearch.UpdateDocumentsByFunction(c, "movies", "doc.title = doc.title.to_upper()", "id < 10", "", err), err)
    meilisearch.Wait(c, meilisearch.DeleteDocument(c, "movies", "5", err), err)
    mut ids := Vector {} as Vector<str>
    ids.push("3")
    ids.push("4")
    meilisearch.Wait(c, meilisearch.DeleteDocuments(c, "movies", ids, err), err)
    meilisearch.Wait(c, meilisearch.DeleteDocumentsByFilter(c, "movies", "id >= 100", err), err)
    meilisearch.Wait(c, meilisearch.DeleteAllDocuments(c, "movies", err), err)
    println meilisearch.ErrorString(err)
end

Constants and variables

MATCH_LAST

const MATCH_LAST: str = "last"
Matching strategy: drop query words from the end until enough documents match. The default.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

MATCH_ALL

const MATCH_ALL: str = "all"
Matching strategy: every query word must match.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

MATCH_FREQUENCY

const MATCH_FREQUENCY: str = "frequency"
Matching strategy: drop the most common words first.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

VERSION

const VERSION: str = "1.0.0"
The version of this client, sent to the server in the X-Meilisearch-Client header.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

STATUS_ENQUEUED

const STATUS_ENQUEUED: str = "enqueued"
Task status: waiting in the queue.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

STATUS_PROCESSING

const STATUS_PROCESSING: str = "processing"
Task status: running.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

STATUS_SUCCEEDED

const STATUS_SUCCEEDED: str = "succeeded"
Task status: done.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

STATUS_FAILED

const STATUS_FAILED: str = "failed"
Task status: failed; see its error.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

STATUS_CANCELED

const STATUS_CANCELED: str = "canceled"
Task status: canceled.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

Functions

GetSettings

func GetSettings(c: Client, uid: str, err &: Error): str
Every setting of an index, as raw JSON.
db-meilisearch-UpdateSettings.salam
import db.meilisearch

func show(items: Vector<str>):
    each s in items:
        print s + " "
    end
    println ""
end

func main:
    c := meilisearch.New("http://127.0.0.1:7700", "masterKey")
    mut err := meilisearch.Error {}
    println meilisearch.GetSettings(c, "movies", err)
    meilisearch.Wait(c, meilisearch.UpdateSettings(c, "movies", `{"rankingRules": ["words", "typo"], "stopWords": ["the"]}`, err), err)
    println meilisearch.GetSetting(c, "movies", "ranking-rules", err)
    meilisearch.Wait(c, meilisearch.UpdateSetting(c, "movies", "pagination", `{"maxTotalHits": 5000}`, err), err)
    meilisearch.Wait(c, meilisearch.ResetSetting(c, "movies", "pagination", err), err)

    mut rankingRules := Vector {} as Vector<str>
    rankingRules.push("words")
    rankingRules.push("typo")
    rankingRules.push("proximity")
    rankingRules.push("attribute")
    rankingRules.push("sort")
    rankingRules.push("exactness")
    meilisearch.Wait(c, meilisearch.UpdateRankingRules(c, "movies", rankingRules, err), err)
    show(meilisearch.GetRankingRules(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetRankingRules(c, "movies", err), err)

    mut searchableAttributes := Vector {} as Vector<str>
    searchableAttributes.push("title")
    searchableAttributes.push("overview")
    meilisearch.Wait(c, meilisearch.UpdateSearchableAttributes(c, "movies", searchableAttributes, err), err)
    show(meilisearch.GetSearchableAttributes(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetSearchableAttributes(c, "movies", err), err)

    mut displayedAttributes := Vector {} as Vector<str>
    displayedAttributes.push("*")
    meilisearch.Wait(c, meilisearch.UpdateDisplayedAttributes(c, "movies", displayedAttributes, err), err)
    show(meilisearch.GetDisplayedAttributes(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetDisplayedAttributes(c, "movies", err), err)

    mut filterableAttributes := Vector {} as Vector<str>
    filterableAttributes.push("genre")
    filterableAttributes.push("year")
    meilisearch.Wait(c, meilisearch.UpdateFilterableAttributes(c, "movies", filterableAttributes, err), err)
    show(meilisearch.GetFilterableAttributes(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetFilterableAttributes(c, "movies", err), err)

    mut sortableAttributes := Vector {} as Vector<str>
    sortableAttributes.push("year")
    meilisearch.Wait(c, meilisearch.UpdateSortableAttributes(c, "movies", sortableAttributes, err), err)
    show(meilisearch.GetSortableAttributes(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetSortableAttributes(c, "movies", err), err)

    mut stopWords := Vector {} as Vector<str>
    stopWords.push("the")
    stopWords.push("a")
    meilisearch.Wait(c, meilisearch.UpdateStopWords(c, "movies", stopWords, err), err)
    show(meilisearch.GetStopWords(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetStopWords(c, "movies", err), err)

    mut dictionary := Vector {} as Vector<str>
    dictionary.push("J. R. R.")
    meilisearch.Wait(c, meilisearch.UpdateDictionary(c, "movies", dictionary, err), err)
    show(meilisearch.GetDictionary(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetDictionary(c, "movies", err), err)

    mut separatorTokens := Vector {} as Vector<str>
    separatorTokens.push("|")
    meilisearch.Wait(c, meilisearch.UpdateSeparatorTokens(c, "movies", separatorTokens, err), err)
    show(meilisearch.GetSeparatorTokens(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetSeparatorTokens(c, "movies", err), err)

    mut nonSeparatorTokens := Vector {} as Vector<str>
    nonSeparatorTokens.push("@")
    meilisearch.Wait(c, meilisearch.UpdateNonSeparatorTokens(c, "movies", nonSeparatorTokens, err), err)
    show(meilisearch.GetNonSeparatorTokens(c, "movies", err))
    meilisearch.Wait(c, meilisearch.ResetNonSeparatorTokens(c, "movies", err), err)

    meilisearch.Wait(c, meilisearch.UpdateDistinctAttribute(c, "movies", "sku", err), err)
    println meilisearch.GetDistinctAttribute(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetDistinctAttribute(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateProximityPrecision(c, "movies", "byAttribute", err), err)
    println meilisearch.GetProximityPrecision(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetProximityPrecision(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdatePrefixSearch(c, "movies", "indexingTime", err), err)
    println meilisearch.GetPrefixSearch(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetPrefixSearch(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateSearchCutoffMs(c, "movies", 150, err), err)
    println meilisearch.GetSearchCutoffMs(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetSearchCutoffMs(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateFacetSearch(c, "movies", true, err), err)
    println meilisearch.GetFacetSearch(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetFacetSearch(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateSynonyms(c, "movies", `{"logan": ["wolverine"], "wolverine": ["logan"]}`, err), err)
    println meilisearch.GetSynonyms(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetSynonyms(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateTypoTolerance(c, "movies", `{"minWordSizeForTypos": {"oneTypo": 4, "twoTypos": 10}}`, err), err)
    println meilisearch.GetTypoTolerance(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetTypoTolerance(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdatePagination(c, "movies", `{"maxTotalHits": 5000}`, err), err)
    println meilisearch.GetPagination(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetPagination(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateFaceting(c, "movies", `{"maxValuesPerFacet": 200}`, err), err)
    println meilisearch.GetFaceting(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetFaceting(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateEmbedders(c, "movies", `{"default": {"source": "userProvided", "dimensions": 3}}`, err), err)
    println meilisearch.GetEmbedders(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetEmbedders(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateLocalizedAttributes(c, "movies", `[{"attributePatterns": ["*_fa"], "locales": ["fas"]}]`, err), err)
    println meilisearch.GetLocalizedAttributes(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetLocalizedAttributes(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.UpdateChat(c, "movies", `{"description": "A movie catalog"}`, err), err)
    println meilisearch.GetChat(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetChat(c, "movies", err), err)
    meilisearch.Wait(c, meilisearch.ResetSettings(c, "movies", err), err)
    println meilisearch.ErrorString(err)
end

UpdateSettings

func UpdateSettings(c: Client, uid: str, settings: str, err &: Error): TaskInfo
Changes several settings at once; pass a JSON object with only the settings to change.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetSettings

func ResetSettings(c: Client, uid: str, err &: Error): TaskInfo
Puts every setting back to its default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetSetting

func GetSetting(c: Client, uid: str, name: str, err &: Error): str
One setting by its route name, such as ranking-rules, as raw JSON; for settings newer than this package.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateSetting

func UpdateSetting(c: Client, uid: str, name: str, value: str, err &: Error): TaskInfo
Changes one setting by its route name, with the right HTTP method for it.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetSetting

func ResetSetting(c: Client, uid: str, name: str, err &: Error): TaskInfo
Puts one setting back to its default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetRankingRules

func GetRankingRules(c: Client, uid: str, err &: Error): Vector<str>
Returns the ranking rules, in order.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateRankingRules

func UpdateRankingRules(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the ranking rules, in order.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetRankingRules

func ResetRankingRules(c: Client, uid: str, err &: Error): TaskInfo
Resets the ranking rules, in order to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetSearchableAttributes

func GetSearchableAttributes(c: Client, uid: str, err &: Error): Vector<str>
Returns the fields searched, most important first.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateSearchableAttributes

func UpdateSearchableAttributes(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the fields searched, most important first.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetSearchableAttributes

func ResetSearchableAttributes(c: Client, uid: str, err &: Error): TaskInfo
Resets the fields searched, most important first to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetDisplayedAttributes

func GetDisplayedAttributes(c: Client, uid: str, err &: Error): Vector<str>
Returns the fields returned in hits.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateDisplayedAttributes

func UpdateDisplayedAttributes(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the fields returned in hits.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetDisplayedAttributes

func ResetDisplayedAttributes(c: Client, uid: str, err &: Error): TaskInfo
Resets the fields returned in hits to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetFilterableAttributes

func GetFilterableAttributes(c: Client, uid: str, err &: Error): Vector<str>
Returns the fields you can filter and facet on; an entry with feature options comes back as its JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateFilterableAttributes

func UpdateFilterableAttributes(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the fields you can filter and facet on; an entry with feature options comes back as its JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetFilterableAttributes

func ResetFilterableAttributes(c: Client, uid: str, err &: Error): TaskInfo
Resets the fields you can filter and facet on; an entry with feature options comes back as its JSON to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetSortableAttributes

func GetSortableAttributes(c: Client, uid: str, err &: Error): Vector<str>
Returns the fields you can sort by.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateSortableAttributes

func UpdateSortableAttributes(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the fields you can sort by.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetSortableAttributes

func ResetSortableAttributes(c: Client, uid: str, err &: Error): TaskInfo
Resets the fields you can sort by to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetStopWords

func GetStopWords(c: Client, uid: str, err &: Error): Vector<str>
Returns the words ignored in queries.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateStopWords

func UpdateStopWords(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the words ignored in queries.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetStopWords

func ResetStopWords(c: Client, uid: str, err &: Error): TaskInfo
Resets the words ignored in queries to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetDictionary

func GetDictionary(c: Client, uid: str, err &: Error): Vector<str>
Returns the words kept whole, such as J. R. R..

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateDictionary

func UpdateDictionary(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the words kept whole, such as J. R. R..

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetDictionary

func ResetDictionary(c: Client, uid: str, err &: Error): TaskInfo
Resets the words kept whole, such as J. R. R. to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetSeparatorTokens

func GetSeparatorTokens(c: Client, uid: str, err &: Error): Vector<str>
Returns the extra characters that split words.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateSeparatorTokens

func UpdateSeparatorTokens(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the extra characters that split words.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetSeparatorTokens

func ResetSeparatorTokens(c: Client, uid: str, err &: Error): TaskInfo
Resets the extra characters that split words to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetNonSeparatorTokens

func GetNonSeparatorTokens(c: Client, uid: str, err &: Error): Vector<str>
Returns the characters that no longer split words.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateNonSeparatorTokens

func UpdateNonSeparatorTokens(c: Client, uid: str, items: Vector<str>, err &: Error): TaskInfo
Sets the characters that no longer split words.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetNonSeparatorTokens

func ResetNonSeparatorTokens(c: Client, uid: str, err &: Error): TaskInfo
Resets the characters that no longer split words to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetDistinctAttribute

func GetDistinctAttribute(c: Client, uid: str, err &: Error): str
Returns the field that keeps only one document for each value.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateDistinctAttribute

func UpdateDistinctAttribute(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets the field that keeps only one document for each value.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetDistinctAttribute

func ResetDistinctAttribute(c: Client, uid: str, err &: Error): TaskInfo
Resets the field that keeps only one document for each value to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetProximityPrecision

func GetProximityPrecision(c: Client, uid: str, err &: Error): str
Returns how word distance is measured: byWord or byAttribute.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateProximityPrecision

func UpdateProximityPrecision(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets how word distance is measured: byWord or byAttribute.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetProximityPrecision

func ResetProximityPrecision(c: Client, uid: str, err &: Error): TaskInfo
Resets how word distance is measured: byWord or byAttribute to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetPrefixSearch

func GetPrefixSearch(c: Client, uid: str, err &: Error): str
Returns when prefix search works: indexingTime or disabled.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdatePrefixSearch

func UpdatePrefixSearch(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets when prefix search works: indexingTime or disabled.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetPrefixSearch

func ResetPrefixSearch(c: Client, uid: str, err &: Error): TaskInfo
Resets when prefix search works: indexingTime or disabled to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetSearchCutoffMs

func GetSearchCutoffMs(c: Client, uid: str, err &: Error): i64
Returns the longest a search may run, in milliseconds; -1 when unset.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateSearchCutoffMs

func UpdateSearchCutoffMs(c: Client, uid: str, value: i64, err &: Error): TaskInfo
Sets the longest a search may run, in milliseconds; -1 when unset.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetSearchCutoffMs

func ResetSearchCutoffMs(c: Client, uid: str, err &: Error): TaskInfo
Resets the longest a search may run, in milliseconds; -1 when unset to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetFacetSearch

func GetFacetSearch(c: Client, uid: str, err &: Error): bool
Returns whether facet search is on.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateFacetSearch

func UpdateFacetSearch(c: Client, uid: str, value: bool, err &: Error): TaskInfo
Sets whether facet search is on.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetFacetSearch

func ResetFacetSearch(c: Client, uid: str, err &: Error): TaskInfo
Resets whether facet search is on to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetSynonyms

func GetSynonyms(c: Client, uid: str, err &: Error): str
Returns the synonyms, as a JSON object of word lists.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateSynonyms

func UpdateSynonyms(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets the synonyms, as a JSON object of word lists.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetSynonyms

func ResetSynonyms(c: Client, uid: str, err &: Error): TaskInfo
Resets the synonyms, as a JSON object of word lists to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetTypoTolerance

func GetTypoTolerance(c: Client, uid: str, err &: Error): str
Returns the typo tolerance options, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateTypoTolerance

func UpdateTypoTolerance(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets the typo tolerance options, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetTypoTolerance

func ResetTypoTolerance(c: Client, uid: str, err &: Error): TaskInfo
Resets the typo tolerance options, as JSON to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetPagination

func GetPagination(c: Client, uid: str, err &: Error): str
Returns the pagination options, such as maxTotalHits, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdatePagination

func UpdatePagination(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets the pagination options, such as maxTotalHits, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetPagination

func ResetPagination(c: Client, uid: str, err &: Error): TaskInfo
Resets the pagination options, such as maxTotalHits, as JSON to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetFaceting

func GetFaceting(c: Client, uid: str, err &: Error): str
Returns the faceting options, such as maxValuesPerFacet, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateFaceting

func UpdateFaceting(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets the faceting options, such as maxValuesPerFacet, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetFaceting

func ResetFaceting(c: Client, uid: str, err &: Error): TaskInfo
Resets the faceting options, such as maxValuesPerFacet, as JSON to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetEmbedders

func GetEmbedders(c: Client, uid: str, err &: Error): str
Returns the embedders for AI powered search, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateEmbedders

func UpdateEmbedders(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets the embedders for AI powered search, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetEmbedders

func ResetEmbedders(c: Client, uid: str, err &: Error): TaskInfo
Resets the embedders for AI powered search, as JSON to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetLocalizedAttributes

func GetLocalizedAttributes(c: Client, uid: str, err &: Error): str
Returns the languages of fields, as a JSON array of rules.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateLocalizedAttributes

func UpdateLocalizedAttributes(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets the languages of fields, as a JSON array of rules.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetLocalizedAttributes

func ResetLocalizedAttributes(c: Client, uid: str, err &: Error): TaskInfo
Resets the languages of fields, as a JSON array of rules to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

GetChat

func GetChat(c: Client, uid: str, err &: Error): str
Returns the conversational search options, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

UpdateChat

func UpdateChat(c: Client, uid: str, value: str, err &: Error): TaskInfo
Sets the conversational search options, as JSON.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

ResetChat

func ResetChat(c: Client, uid: str, err &: Error): TaskInfo
Resets the conversational search options, as JSON to the default.

The example for this item is shown with the ones above: db-meilisearch-UpdateSettings.salam

func Search(c: Client, uid: str, r: SearchRequest, err &: Error): SearchResult
Searches an index. On error the result is empty and the error is filled.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

Query

func Query(c: Client, uid: str, q: str, err &: Error): SearchResult
Searches an index for some words with every other option left at its default.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

HitsAs

func HitsAs<T>(r: SearchResult, out &: Vector<T>, err &: Error): bool
Reads every hit into Salam structs; fields like _formatted that the struct does not have are ignored.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

MultiSearch

func MultiSearch(c: Client, queries: Vector<MultiQuery>, err &: Error): Vector<SearchResult>
Runs several searches in one request and returns one result each.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

FederatedSearch

func FederatedSearch(c: Client, queries: Vector<MultiQuery>, f: Federation, 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-meilisearch-Search.salam

FacetSearch

func FacetSearch(c: Client, uid: str, r: FacetSearchRequest, err &: Error): FacetSearchResult
Searches among the values of a facet, for a filter box that completes as you type.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

SimilarDocuments

func SimilarDocuments(c: Client, uid: str, r: SimilarRequest, err &: Error): SearchResult
Documents that resemble a given document; the index needs an embedder.

The example for this item is shown with the ones above: db-meilisearch-Search.salam

Health

func Health(c: Client, err &: Error): str
The health status: available when the server is up.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

IsHealthy

func IsHealthy(c: Client): bool
The server answers and is available.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

GetVersion

func GetVersion(c: Client, err &: Error): Version
The server version.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

GetStats

func GetStats(c: Client, err &: Error): Stats
Statistics of the whole instance.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

CreateDump

func CreateDump(c: Client, err &: Error): TaskInfo
Starts a dump, a portable backup of every index.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

CreateSnapshot

func CreateSnapshot(c: Client, err &: Error): TaskInfo
Starts a snapshot of the database.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

GetExperimentalFeatures

func GetExperimentalFeatures(c: Client, err &: Error): str
The experimental features and whether each is on, as raw JSON.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

UpdateExperimentalFeatures

func UpdateExperimentalFeatures(c: Client, features: str, err &: Error): str
Turns experimental features on or off; pass a JSON object such as {"metrics": true}.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

GetNetwork

func GetNetwork(c: Client, err &: Error): str
The network settings used for federated search across instances, as raw JSON.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

UpdateNetwork

func UpdateNetwork(c: Client, network: str, err &: Error): str
Changes the network settings.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

Export

func Export(c: Client, request: str, err &: Error): TaskInfo
Starts sending indexes to another Meilisearch; pass the JSON body of the export route.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

GetMetrics

func GetMetrics(c: Client, err &: Error): str
The Prometheus metrics as text; the metrics feature must be on.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

New

func New(host: str, api_key: str): Client
Makes a client. A missing http:// is added and a trailing slash is dropped.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

WithAgent

func WithAgent(c: Client, agent: str): Client
A copy of the client that names your app in the client header.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

ErrorString

func ErrorString(err: Error): str
The error as one line, such as meilisearch 404 [index_not_found]: Index `movies` not found.; empty when there is no error.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

Request

func Request(c: Client, method: str, path: str, body: str, err &: Error): str
Sends any request with a JSON body and returns the raw response body; for routes with no function of their own.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

RequestAs

func RequestAs(c: Client, method: str, path: str, content_type: str, body: str, err &: Error): str
The same, with the content type you choose.

The example for this item is shown with the ones above: db-meilisearch-Client.salam

GetTask

func GetTask(c: Client, uid: i64, err &: Error): Task
One task.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

GetTasks

func GetTasks(c: Client, q: TaskQuery, err &: Error): TaskPage
A page of tasks.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

WaitForTask

func WaitForTask(c: Client, uid: i64, timeout_ms: int, interval_ms: int, err &: Error): Task
Polls a task every few milliseconds until it ends. A failed task fills the error with the task error; running past the timeout gives the code timeout. A timeout of 0 waits forever.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

Wait

func Wait(c: Client, info: TaskInfo, err &: Error): Task
Waits up to five seconds for the task of a write; does nothing when the write itself already failed, so you can chain it.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

CancelTasks

func CancelTasks(c: Client, q: TaskQuery, err &: Error): TaskInfo
Cancels the queued or running tasks that match; at least one filter is required.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

DeleteTasks

func DeleteTasks(c: Client, q: TaskQuery, err &: Error): TaskInfo
Deletes finished tasks from the history; at least one filter is required.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

GetBatch

func GetBatch(c: Client, uid: i64, err &: Error): Batch
One batch.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

GetBatches

func GetBatches(c: Client, q: TaskQuery, err &: Error): BatchPage
A page of batches, filtered the same way as tasks.

The example for this item is shown with the ones above: db-meilisearch-GetTasks.salam

CreateKey

func CreateKey(c: Client, r: KeyRequest, err &: Error): Key
Creates an API key; needs the master key.

The example for this item is shown with the ones above: db-meilisearch-CreateKey.salam

GetKey

func GetKey(c: Client, key_or_uid: str, err &: Error): Key
One key, by its uid or its value.

The example for this item is shown with the ones above: db-meilisearch-CreateKey.salam

GetKeys

func GetKeys(c: Client, offset: int, limit: int, err &: Error): KeyPage
A page of keys.

The example for this item is shown with the ones above: db-meilisearch-CreateKey.salam

UpdateKey

func UpdateKey(c: Client, key_or_uid: str, name: str, description: str, err &: Error): Key
Changes the name and description of a key; nothing else of a key can change.

The example for this item is shown with the ones above: db-meilisearch-CreateKey.salam

DeleteKey

func DeleteKey(c: Client, key_or_uid: str, err &: Error): bool
Deletes a key; it stops working at once.

The example for this item is shown with the ones above: db-meilisearch-CreateKey.salam

TenantToken

func TenantToken(api_key_uid: str, api_key: str, search_rules: str, expires_at: i64, err &: Error): str
Signs a tenant token for one user: a search key that applies your filter rules to every search, made with no request to the server. Pass the uid and value of a key that may search, the search rules as JSON (empty means every index) and a Unix expiry time (0 for none).

The example for this item is shown with the ones above: db-meilisearch-CreateKey.salam

CreateIndex

func CreateIndex(c: Client, uid: str, primary_key: str, err &: Error): TaskInfo
Creates an index; leave the primary key empty to let Meilisearch guess it from the first documents.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

GetIndex

func GetIndex(c: Client, uid: str, err &: Error): Index
One index.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

ListIndexes

func ListIndexes(c: Client, offset: int, limit: int, err &: Error): IndexPage
A page of indexes; 0 for offset and limit means the server defaults.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

UpdateIndex

func UpdateIndex(c: Client, uid: str, primary_key: str, err &: Error): TaskInfo
Sets the primary key of an index that has no documents yet.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

RenameIndex

func RenameIndex(c: Client, uid: str, new_uid: str, err &: Error): TaskInfo
Gives an index a new name.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

DeleteIndex

func DeleteIndex(c: Client, uid: str, err &: Error): TaskInfo
Deletes an index and all its documents.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

SwapIndexes

func SwapIndexes(c: Client, swaps: Vector<IndexSwap>, err &: Error): TaskInfo
Swaps the contents of index pairs in one atomic step; the way to rebuild an index with no downtime.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

GetIndexStats

func GetIndexStats(c: Client, uid: str, err &: Error): IndexStats
Statistics of one index.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.salam

AddDocuments

func AddDocuments(c: Client, uid: str, documents: str, primary_key: str, err &: Error): TaskInfo
Adds documents, or replaces those with the same id; pass a JSON array or object.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

UpdateDocuments

func UpdateDocuments(c: Client, uid: str, documents: str, primary_key: str, err &: Error): TaskInfo
Adds documents, or merges the given fields into those with the same id.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

AddDocumentsNdjson

func AddDocumentsNdjson(c: Client, uid: str, documents: str, primary_key: str, err &: Error): TaskInfo
Adds documents written as NDJSON, one JSON object per line.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

UpdateDocumentsNdjson

func UpdateDocumentsNdjson(c: Client, uid: str, documents: str, primary_key: str, err &: Error): TaskInfo
Merges NDJSON documents.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

AddDocumentsCsv

func AddDocumentsCsv(c: Client, uid: str, documents: str, primary_key: str, delimiter: str, err &: Error): TaskInfo
Adds documents written as CSV; empty delimiter means a comma. Write year:number in the header for a number column.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

UpdateDocumentsCsv

func UpdateDocumentsCsv(c: Client, uid: str, documents: str, primary_key: str, delimiter: str, err &: Error): TaskInfo
Merges CSV documents.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

AddDocumentsInBatches

func AddDocumentsInBatches(c: Client, uid: str, documents: Vector<str>, batch_size: int, primary_key: str, err &: Error): Vector<TaskInfo>
Adds many documents, given one JSON object each, in batches of the given size; returns one task per batch.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

AddDocumentsOf

func AddDocumentsOf<T>(c: Client, uid: str, documents: Vector<T>, primary_key: str, err &: Error): TaskInfo
Adds Salam structs as documents; each one is turned into JSON.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

GetDocument

func GetDocument(c: Client, uid: str, id: str, fields: Vector<str>, err &: Error): str
One document as raw JSON; an empty list of fields returns them all.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

GetDocumentAs

func GetDocumentAs<T>(c: Client, uid: str, id: str, out &: T, err &: Error): bool
One document read into a Salam struct; fields the struct does not have are ignored.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

GetDocuments

func GetDocuments(c: Client, uid: str, q: DocumentsQuery, err &: Error): Page
A page of documents.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

DocumentsAs

func DocumentsAs<T>(p: Page, out &: Vector<T>, err &: Error): bool
Reads every document of a page into Salam structs.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

DeleteDocument

func DeleteDocument(c: Client, uid: str, id: str, err &: Error): TaskInfo
Deletes one document.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

DeleteDocuments

func DeleteDocuments(c: Client, uid: str, ids: Vector<str>, err &: Error): TaskInfo
Deletes the documents with these ids.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

DeleteDocumentsByFilter

func DeleteDocumentsByFilter(c: Client, uid: str, filter: str, err &: Error): TaskInfo
Deletes the documents that match a filter.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

DeleteAllDocuments

func DeleteAllDocuments(c: Client, uid: str, err &: Error): TaskInfo
Deletes every document but keeps the index and its settings.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam

UpdateDocumentsByFunction

func UpdateDocumentsByFunction(c: Client, uid: str, function: str, filter: str, context: str, err &: Error): TaskInfo
Changes documents with a Rhai script, optionally only those matching a filter and with a JSON context; needs the editDocumentsByFunction feature.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.salam