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 talks to 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, webhooks, dynamic search rules and chat workspaces. This page starts with a tutorial; the full reference of every function and type comes after it.

Tutorial: a movie search in eleven steps

The steps below build one small movie catalogue and search it. Each step is a complete program, and the output under it is what it printed against a real Meilisearch 1.55. Run them in order, because each step uses the data the earlier ones left behind.

First start a server. With Docker that is one command; without it, download the meilisearch binary from the Meilisearch releases page and run it with the same key:

docker run -p 7700:7700 -e MEILI_MASTER_KEY=masterKey getmeili/meilisearch:v1.55.0

The programs assume http://127.0.0.1:7700 and the master key masterKey. A real deployment uses a long random master key and gives applications smaller keys, as step 9 shows.

1. Connect

New makes a client: a plain value with the address and the key, which threads can share. WithTimeout returns a copy that stops waiting after the given milliseconds; without it a request waits as long as the server takes. Every call that can fail takes an Error as its last argument. Ok tells you whether the call worked and ErrorString turns the error into one line.

meili-connect.salam
import db.meilisearch

func main:
    c := meilisearch.WithTimeout(meilisearch.New("http://127.0.0.1:7700", "masterKey"), 5000)
    if not meilisearch.IsHealthy(c):
        println "Meilisearch is not running at " + c.host
        ret 1
    end
    mut err := meilisearch.Error {}
    version := meilisearch.GetVersion(c, err)
    println "connected to Meilisearch " + version.pkg_version

    meilisearch.GetIndex(c, "no_such_index", err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
    end
    ret 0
end
Output
connected to Meilisearch 1.55.0
meilisearch 404 [index_not_found]: Index `no_such_index` not found.

The error carries everything Meilisearch sent: the HTTP status, the code to branch on (here index_not_found), the message and a link to its documentation. When the server cannot be reached at all, code is communication_error, or timeout when the time limit ran out.

2. Create an index and add documents

An index is a named collection of documents, each with a unique primary key. Documents can be Salam structs: AddDocumentsOf turns each one into JSON. AddDocuments takes JSON text instead, and AddDocumentsNdjson and AddDocumentsCsv take those formats.

meili-index.salam
import db.meilisearch

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

func movie(id: int, title: str, genre: str, year: int, overview: str): Movie:
    ret Movie {
        id = id,
        title = title,
        genre = genre,
        year = year,
        overview = overview
    }
end

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

    meilisearch.Wait(c, meilisearch.CreateIndex(c, "movies", "id", err), err)

    mut movies := Vector {} as Vector<Movie>
    movies.Push(
        movie(
            1,
            "Heat",
            "Crime",
            1995,
            "A detective hunts a crew of professional thieves in Los Angeles."
        )
    )
    movies.Push(
        movie(2, "Moana", "Family", 2016, "A girl sails across the ocean to save her island.")
    )
    movies.Push(
        movie(3, "Alien", "Horror", 1979, "The crew of a space freighter meets a deadly creature.")
    )
    movies.Push(
        movie(
            4, "Up", "Family", 2009, "An old man flies his house away with thousands of balloons."
        )
    )
    movies.Push(
        movie(
            5,
            "Arrival",
            "Drama",
            2016,
            "A linguist learns to talk with visitors from another world."
        )
    )
    movies.Push(movie(6, "Dune", "Adventure", 2021, "A young noble fights for a desert planet."))
    movies.Push(
        movie(
            7,
            "Interstellar",
            "Drama",
            2014,
            "Explorers travel through a wormhole to find a new home."
        )
    )
    movies.Push(
        movie(8, "Coco", "Family", 2017, "A boy enters the land of the dead to find his family.")
    )

    task := meilisearch.Wait(c, meilisearch.AddDocumentsOf(c, "movies", movies, "id", err), err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        ret 1
    end
    println "indexing: " + task.status
    stats := meilisearch.GetIndexStats(c, "movies", err)
    println "documents in movies: " + stats.number_of_documents
    ret 0
end
Output
indexing: succeeded
documents in movies: 8

Meilisearch does not apply a change at once. A write returns a TaskInfo, a receipt with a task number, and the server applies the tasks in order in the background. Wait blocks until that task has finished, which is what you want when the next line depends on the change. A batch import does not need to wait after every call; wait once at the end, or not at all.

3. Search

Query searches for some words with every option at its default. The hits come back as JSON text, and HitsAs reads them into your own struct. A struct with fewer fields than the document is fine: the extra fields are ignored.

meili-search.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 {}

    res := meilisearch.Query(c, "movies", "spcae", err)
    println "hits for \"" + res.query + "\": " + res.estimated_total_hits
    mut movies := Vector {} as Vector<Movie>
    if meilisearch.HitsAs(res, movies, err):
        each m in movies:
            println "  " + m.title + " (" + m.year + ")"
        end
    end
    ret 0
end
Output
hits for "spcae": 1
  Alien (1979)

The query was misspelled on purpose: spcae still finds the movie whose overview says space, because Meilisearch tolerates typos out of the box.

4. Filter, sort and count facets

Filtering and sorting need to be switched on for the fields involved; that is a setting of the index, and UpdateSettings changes several settings in one task. A SearchRequest holds every search option and sends only the ones you set.

meili-filter.salam
import db.meilisearch

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

    settings := `{"filterableAttributes": ["genre", "year"], "sortableAttributes": ["year"]}`
    meilisearch.Wait(c, meilisearch.UpdateSettings(c, "movies", settings, err), err)

    mut req := meilisearch.SearchRequest { filter = "genre = Family AND year > 2010" }
    req.sort.Push("year:desc")
    req.facets.Push("genre")
    req.attributes_to_retrieve.Push("title")
    req.attributes_to_retrieve.Push("year")
    res := meilisearch.Search(c, "movies", req, err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        ret 1
    end
    each hit in res.hits:
        println hit
    end

    all := meilisearch.Search(
        c, "movies", meilisearch.SearchRequest { facets = req.facets, limit = 0 }, err
    )
    println "genres: " + all.facet_distribution
    ret 0
end
Output
{"title":"Coco","year":2017}
{"title":"Moana","year":2016}
genres: {"genre":{"Adventure":1,"Crime":1,"Drama":2,"Family":3,"Horror":1}}

facets asks how many hits have each value of a field, which is how a search page shows filter options with counts. attributes_to_retrieve keeps the hits small by returning only the fields you need.

5. Highlight, crop and page through results

For a results page you usually want the matched words marked and long text cut down around them. Meilisearch adds a _formatted copy of each hit with both done. page and hits_per_page give numbered pages with an exact total; offset and limit are the cheaper choice for endless scrolling.

meili-highlight.salam
import db.meilisearch
import encoding.json

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

    mut req := meilisearch.SearchRequest { query = "crew", hits_per_page = 1, page = 1 }
    req.attributes_to_highlight.Push("overview")
    req.highlight_pre_tag = "["
    req.highlight_post_tag = "]"
    req.attributes_to_crop.Push("overview")
    req.crop_length = 6
    res := meilisearch.Search(c, "movies", req, err)
    println "page " + res.page + " of " + res.total_pages + ", " + res.total_hits + " hits"
    each hit in res.hits:
        formatted := json.Get(hit, "_formatted")
        println json.Get(hit, "title") + ": " + json.Get(formatted, "overview")
    end
    ret 0
end
Output
page 1 of 2, 2 hits
Alien: The [crew] of a space freighter…

6. Tune relevancy

Every index setting has its own Get, Update and Reset function. Synonyms make different words find each other, stop words are ignored in queries, and the searchable attributes choose which fields are searched and how much each one counts.

meili-settings.salam
import db.meilisearch

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

    meilisearch.Wait(
        c,
        meilisearch.UpdateSynonyms(
            c, "movies", `{"cartoon": ["family"], "space": ["planet", "wormhole"]}`, err
        ),
        err
    )
    mut stop := Vector {} as Vector<str>
    stop.Push("the")
    stop.Push("a")
    meilisearch.Wait(c, meilisearch.UpdateStopWords(c, "movies", stop, err), err)
    mut searchable := Vector {} as Vector<str>
    searchable.Push("title")
    searchable.Push("overview")
    meilisearch.Wait(c, meilisearch.UpdateSearchableAttributes(c, "movies", searchable, err), err)

    res := meilisearch.Query(c, "movies", "cartoon", err)
    println "hits for \"cartoon\", a synonym of family: " + res.estimated_total_hits
    space := meilisearch.Query(c, "movies", "space", err)
    println "hits for \"space\": " + space.estimated_total_hits
    println "searchable: " + meilisearch.GetSetting(c, "movies", "searchable-attributes", err)
    ret 0
end
Output
hits for "cartoon", a synonym of family: 1
hits for "space": 3
searchable: ["title","overview"]

Other settings follow the same pattern: UpdateRankingRules, UpdateTypoTolerance, UpdateDistinctAttribute, UpdatePagination, UpdateFaceting, UpdateDictionary and the rest in the reference below. GetSetting and UpdateSetting reach any setting by its route name, including ones newer than this package.

7. Search several indexes at once

MultiSearch sends several searches in one request and returns one result each. FederatedSearch merges them into a single ranked list, which suits one search box over different kinds of content. FacetSearch searches the values of one facet, for a filter box that completes as you type.

meili-multi.salam
import db.meilisearch

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

    meilisearch.Wait(
        c,
        meilisearch.AddDocuments(
            c,
            "books",
            `[{"id": 1, "title": "Dune", "author": "Frank Herbert"}, {"id": 2, "title": "Coco and the Moon", "author": "A. Writer"}]`,
            "id",
            err
        ),
        err
    )

    mut queries := Vector {} as Vector<meilisearch.MultiQuery>
    queries.Push(
        meilisearch.MultiQuery {
            index_uid = "movies", request = meilisearch.SearchRequest { query = "dune" }
        }
    )
    queries.Push(
        meilisearch.MultiQuery {
            index_uid = "books", request = meilisearch.SearchRequest { query = "dune" }
        }
    )
    each r in meilisearch.MultiSearch(c, queries, err):
        println r.index_uid + ": " + r.hits.Len() + " hit"
    end

    merged := meilisearch.FederatedSearch(c, queries, meilisearch.Federation { limit = 5 }, err)
    println "federated: " + merged.hits.Len() + " hits in one list"

    genres := meilisearch.FacetSearch(
        c,
        "movies",
        meilisearch.FacetSearchRequest { facet_name = "genre", facet_query = "fam" },
        err
    )
    each g in genres.hits:
        println "genre " + g.value + ": " + g.count
    end
    ret 0
end
Output
movies: 1 hit
books: 1 hit
federated: 2 hits in one list
genre Family: 3

8. Vector and hybrid search

Meilisearch can also search by meaning. An embedder turns documents into vectors; it can call a model such as OpenAI or Hugging Face, or take vectors you computed yourself, which is what the userProvided source in this step does. A search with hybrid_embedder mixes keyword and vector results; a hybrid_semantic_ratio of 1 uses vectors only. SimilarDocuments finds the documents nearest to one you already have.

meili-vectors.salam
import db.meilisearch

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

    meilisearch.Wait(c, meilisearch.CreateIndex(c, "movies_ai", "id", err), err)
    meilisearch.Wait(
        c,
        meilisearch.UpdateEmbedders(
            c, "movies_ai", `{"manual": {"source": "userProvided", "dimensions": 3}}`, err
        ),
        err
    )
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        ret 1
    end
    docs := `[
        {"id": 2, "title": "Moana", "_vectors": {"manual": [0.9, 0.1, 0.0]}},
        {"id": 4, "title": "Up", "_vectors": {"manual": [0.8, 0.2, 0.1]}},
        {"id": 5, "title": "Arrival", "_vectors": {"manual": [0.1, 0.9, 0.3]}},
        {"id": 6, "title": "Dune", "_vectors": {"manual": [0.2, 0.8, 0.4]}},
        {"id": 7, "title": "Interstellar", "_vectors": {"manual": [0.1, 0.8, 0.5]}},
        {"id": 8, "title": "Coco", "_vectors": {"manual": [0.9, 0.0, 0.1]}}
    ]`
    task := meilisearch.Wait(c, meilisearch.AddDocuments(c, "movies_ai", docs, "", err), err)
    println "vectors stored: " + task.status

    mut req := meilisearch.SearchRequest {
        hybrid_embedder = "manual", hybrid_semantic_ratio = 1.0, limit = 2
    }
    req.vector.Push(0.15)
    req.vector.Push(0.85)
    req.vector.Push(0.4)
    req.attributes_to_retrieve.Push("title")
    res := meilisearch.Search(c, "movies_ai", req, err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        ret 1
    end
    each hit in res.hits:
        println "close to the query: " + hit
    end

    mut like := meilisearch.SimilarRequest { id = "2", embedder = "manual", limit = 2 }
    like.attributes_to_retrieve.Push("title")
    each hit in meilisearch.SimilarDocuments(c, "movies_ai", like, err).hits:
        println "like Moana: " + hit
    end
    ret 0
end
Output
vectors stored: succeeded
close to the query: {"title":"Dune"}
close to the query: {"title":"Arrival"}
like Moana: {"title":"Coco"}
like Moana: {"title":"Up"}

A userProvided embedder needs a vector in every document, so this step uses its own index. Add the embedder while the index is still empty and send the vectors in each document under _vectors.

9. API keys and tenant tokens

The master key can do everything, so applications should get smaller keys. CreateKey makes a key limited to some actions and indexes. A tenant token goes one step further: TenantToken signs, in your own program and without asking the server, a key that adds a filter to every search. Give each user their own token and they can search directly from the browser while seeing only their rows.

meili-keys.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 = "Shop front end", description = "Search the movies index only"
    }
    r.actions.Push("search")
    r.indexes.Push("movies")
    key := meilisearch.CreateKey(admin, r, err)
    println "new key " + key.name + " can: " + key.actions.Get(0)

    rules := `{"movies": {"filter": "genre = Family"}}`
    token := meilisearch.TenantToken(key.uid, key.key, rules, time.Now() + 3600, err)
    kids := meilisearch.New("http://127.0.0.1:7700", token)
    res := meilisearch.Query(kids, "movies", "", err)
    println "the token sees " + res.estimated_total_hits + " family movies"

    meilisearch.Query(kids, "books", "", err)
    println "books with the token: " + err.code

    println "key deleted: " + meilisearch.DeleteKey(admin, key.uid, err)
    ret 0
end
Output
new key Shop front end can: search
the token sees 3 family movies
books with the token: invalid_api_key
key deleted: true

10. Update and delete documents

AddDocuments replaces a whole document with the same id; UpdateDocuments changes only the fields you send. Documents can be deleted one by one, by a list of ids, by a filter, or all at once.

meili-update.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 {}

    meilisearch.Wait(
        c,
        meilisearch.UpdateDocuments(c, "movies", `[{"id": 6, "title": "Dune: Part One"}]`, "", err),
        err
    )
    mut dune := Movie {}
    if meilisearch.GetDocumentAs(c, "movies", "6", dune, err):
        println "renamed: " + dune.title + " (" + dune.year + ")"
    end

    meilisearch.Wait(c, meilisearch.DeleteDocument(c, "movies", "3", err), err)
    meilisearch.GetDocument(c, "movies", "3", Vector {} as Vector<str>, err)
    println "after delete: " + err.code

    removed := meilisearch.Wait(
        c, meilisearch.DeleteDocumentsByFilter(c, "movies", "year < 2000", err), err
    )
    println "delete by filter: " + removed.status + " " + removed.details
    println "left: " + meilisearch.GetIndexStats(c, "movies", err).number_of_documents
    ret 0
end
Output
renamed: Dune: Part One (2021)
after delete: document_not_found
delete by filter: succeeded {"providedIds":0,"deletedDocuments":1,"originalFilter":"\"year < 2000\""}
left: 6

11. Tasks and failures

A write that is accepted can still fail later, while the server applies it. The error then lives on the task, not on the call that queued it. WaitForTask copies it into your Error, so the usual check works. GetTasks lists past tasks with filters on index, type, status and dates.

meili-tasks.salam
import db.meilisearch

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

    info := meilisearch.AddDocuments(c, "movies", `[{"title": "No id here"}]`, "", err)
    println "queued task " + info.task_uid + ": " + info.status
    task := meilisearch.WaitForTask(c, info.task_uid, 10000, 50, err)
    println "finished as " + task.status
    if not meilisearch.Ok(err):
        println "why: " + err.code
    end

    mut q := meilisearch.TaskQuery { limit = 3 }
    q.index_uids.Push("movies")
    q.statuses.Push(meilisearch.STATUS_SUCCEEDED)
    page := meilisearch.GetTasks(c, q, err)
    println "recent successful tasks on movies:"
    each t in page.results:
        println "  " + t.kind
    end
    ret 0
end
Output
queued task 13: enqueued
finished as failed
why: missing_document_id
recent successful tasks on movies:
  documentDeletion
  documentDeletion
  documentAdditionOrUpdate

More

The rest of the API works the same way; the reference below covers each function. A few pointers:

•

CreateWebhook registers a URL that Meilisearch calls when tasks finish, so you do not need to poll.

•

UpdateSearchRule pins or boosts chosen documents for chosen queries, such as a sale banner for sale; it needs the dynamicSearchRules experimental feature.

•

UpdateChatSettings and ChatCompletion answer questions in plain language from your indexes through an LLM; they need the chatCompletions feature.

•

WithMetadata tags every document write with a label that comes back on the task, to follow one import through the task list.

•

CreateDump, CreateSnapshot, GetStats, GetMetrics and SetStderrLogs are for running the server.

•

For a route with no function of its own, Request sends any method, path and JSON body.

The Salam repository has one runnable example for each part of the API, in English under tests/en/stdlib/meilisearch/examples and in Persian under tests/fa/stdlib/meilisearch/examples.

Types

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.CompactIndex(c, "movies", err), err)
    mut fq := meilisearch.FieldsQuery { offset = 0, limit = 50, filter = `{"filterable": true}` }
    fq.attribute_patterns.Push("*")
    fields := meilisearch.ListFields(c, "movies", fq, err)
    println fields.total, fields.offset, fields.limit
    each f in fields.results:
        println f.name,
            f.displayed,
            f.searchable,
            f.sortable,
            f.distinct,
            f.filterable,
            f.ranking_rule,
            f.localized,
            f.raw.Len()
    end
    println s.index_size, s.used_index_size, s.internal_database_sizes
    meilisearch.Wait(c, meilisearch.DeleteIndex(c, "films", err), err)
end

IndexPage

#
struct IndexPage

One page of indexes.

NameTypeDescription
resultsVector<Index>The 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.
index_sizei64 = 0The size of the index on disk, in bytes.
used_index_sizei64 = 0The bytes of the index actually in use.
internal_database_sizesstr = ""The size of each internal database, 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

Field

#
struct Field

One field of an index and what it is used for.

NameTypeDescription
namestr = ""The field name.
displayedbool = falseIt is returned in hits.
searchablebool = falseIt is searched.
sortablebool = falseYou can sort by it.
distinctbool = falseIt is the distinct attribute.
filterablebool = falseYou can filter on it.
ranking_rulestr = ""Its ranking rule settings, as raw JSON.
localizedstr = ""Its languages, as raw JSON.
rawstr = ""The whole field entry.

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

FieldsQuery

#
struct FieldsQuery

Which fields ListFields returns.

NameTypeDescription
offsetint = -1How many to skip; -1 leaves it out.
limitint = -1How many to return; -1 leaves it out.
attribute_patternsVector<str>Only fields matching these patterns, such as title or *_date.
filterstr = ""More conditions as a JSON object, such as {"filterable": true}.

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

FieldPage

#
struct FieldPage

One page of fields.

NameTypeDescription
resultsVector<Field>The fields.
offseti64 = 0How many were skipped.
limiti64 = 0The page size.
totali64 = 0How many fields match.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.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.
actionsVector<str>What it may do, such as search or * for everything.
indexesVector<str>Which 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.
actionsVector<str>What it may do.
indexesVector<str>Which 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
resultsVector<Key>The 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

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

    quick := meilisearch.WithTimeout(c, 2000)
    println quick.timeout_ms, meilisearch.IsHealthy(quick)
    tagged := meilisearch.WithMetadata(c, "nightly-import")
    println tagged.metadata
    println meilisearch.SetStderrLogs(c, "info", err)
    println meilisearch.RenderTemplate(
        c,
        `{"template": {"kind": "inlineDocumentTemplate", "inline": "{{doc.title}}"}, "input": {"kind": "inlineDocument", "inline": {"title": "Up"}}}`,
        err
    )
    println meilisearch.NetworkControl(
        c,
        `{"origin": {"remoteName": "ms-0", "taskUid": 1}, "message": {"type": "exportNoIndexForRemote", "remote": "ms-1"}}`,
        err
    )
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

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.
facetsVector<str>Count the values of these fields among the hits.
attributes_to_retrieveVector<str>Return only these fields.
attributes_to_cropVector<str>Cut 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_highlightVector<str>Wrap 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.
sortVector<str>Sort 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_onVector<str>Search only these fields.
distinctstr = ""Return at most one hit for each value of this field.
localesVector<str>The languages of the query, such as fas.
vectorVector<f64>Search 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.
show_performance_detailsbool = falseReturn how long each step of the search took.
use_networkbool = falseSearch every instance of a sharded network.
personalizestr = ""Personalization options as raw JSON, such as {"userContext": "..."}.
inline_rulestr = ""A dynamic search rule for this search only, as raw JSON.
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()

    mut more := meilisearch.SearchRequest {
        query = "space",
        show_performance_details = true,
        use_network = false,
        personalize = `{"userContext": "likes old films"}`,
        inline_rule = `{"actions": {"pin": [{"id": "1", "position": 0}]}}`
    }
    more.locales.Push("eng")
    detailed := meilisearch.Search(c, "movies", more, err)
    println detailed.request_uid,
        detailed.performance_details,
        detailed.query_vector,
        detailed.remote_errors,
        detailed.metadata,
        detailed.facets_by_index
    mut fq := meilisearch.FacetSearchRequest {
        facet_name = "genre",
        ranking_score_threshold = 0.1,
        hybrid_embedder = "default",
        hybrid_semantic_ratio = 0.5,
        media = "",
        use_network = false
    }
    fq.locales.Push("eng")
    fq.vector.Push(0.2)
    println meilisearch.FacetSearch(c, "movies", fq, err).remote_errors
    mut posq := Vector {} as Vector<meilisearch.MultiQuery>
    posq.Push(
        meilisearch.MultiQuery {
            index_uid = "movies",
            request = meilisearch.SearchRequest { query = "up" },
            query_position = 0
        }
    )
    println meilisearch.FederatedSearch(
        c,
        posq,
        meilisearch.Federation {
            distinct = "studio", personalize = "", show_performance_details = true
        },
        err
    ).hits.Len()
    println meilisearch.SimilarDocuments(
        c,
        "movies",
        meilisearch.SimilarRequest {
            id = "1", embedder = "default", show_performance_details = true
        },
        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.
hitsVector<str>Each 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.
performance_detailsstr = ""How long each step took, as raw JSON.
query_vectorstr = ""The vector the query was turned into, as raw JSON.
remote_errorsstr = ""Errors from other instances of a sharded network, as raw JSON.
request_uidstr = ""The id of this search request.
metadatastr = ""Extra information about the query, as raw JSON.
facets_by_indexstr = ""The facets of each index, in a federated search.
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.
query_positionint = -1In a federated search, the position used to break ties; -1 leaves it out.

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.
distinctstr = ""Return at most one merged hit for each value of this field.
personalizestr = ""Personalization options for the merged list, as raw JSON.
show_performance_detailsbool = falseReturn how long each step took.

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_onVector<str>Search only these fields.
exhaustive_facet_countbool = falseCount exactly, which is slower.
ranking_score_thresholdf64 = -1Count only documents scoring at least this.
localesVector<str>The languages of the query.
vectorVector<f64>Search by this vector.
hybrid_embedderstr = ""The embedder for hybrid search.
hybrid_semantic_ratiof64 = -1How much meaning outweighs keywords.
mediastr = ""Raw JSON media for multimodal search.
use_networkbool = falseAsk every instance of a sharded network.

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
hitsVector<FacetHit>The matching values.
facet_querystr = ""The facet query that was run.
processing_time_msi64 = 0How long it took, in milliseconds.
remote_errorsstr = ""Errors from other instances, as raw JSON.

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_retrieveVector<str>Return 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.
show_performance_detailsbool = falseReturn how long each step took.

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

SearchRule

#
struct SearchRule

A dynamic search rule: when its conditions hold, its actions pin or boost documents.

NameTypeDescription
uidstr = ""The rule name.
last_updated_atstr = ""When it last changed.
precedencei64 = -1Which rule wins when several match; -1 when unset.
activebool = falseIt is on.
conditionsstr = ""When it applies, as raw JSON: a time range, query words or filter values.
actionsstr = ""What it does, as raw JSON: pin and scale.
rawstr = ""The whole rule.
db-meilisearch-UpdateSearchRule.salam
import db.meilisearch

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

    rule := `{"active": true, "precedence": 1, "conditions": {"query": {"words": "sale"}}, "actions": {"pin": [{"id": "42", "position": 0}]}}`
    meilisearch.Wait(c, meilisearch.UpdateSearchRule(c, "black-friday", rule, err), err)
    r := meilisearch.GetSearchRule(c, "black-friday", err)
    println r.uid, r.active, r.precedence, r.last_updated_at, r.conditions, r.actions, r.raw.Len()

    page := meilisearch.ListSearchRules(c, meilisearch.SearchRuleQuery {
        offset = 0,
        limit = 20,
        query = "sale",
        active = 1
    }, err)
    println page.total, page.offset, page.limit
    each one in page.results:
        println one.uid
    end
    meilisearch.Wait(c, meilisearch.DeleteSearchRule(c, "black-friday", err), err)
    meilisearch.Wait(c, meilisearch.DeleteAllSearchRules(c, err), err)
end

SearchRuleQuery

#
struct SearchRuleQuery

Which rules ListSearchRules returns.

NameTypeDescription
offsetint = -1How many to skip; -1 leaves it out.
limitint = -1How many to return; -1 leaves it out.
querystr = ""Only rules matching this text.
activeint = -11 for active rules only, 0 for inactive ones, -1 for both.

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

SearchRulePage

#
struct SearchRulePage

One page of rules.

NameTypeDescription
resultsVector<SearchRule>The rules.
offseti64 = 0How many were skipped.
limiti64 = 0The page size.
totali64 = 0How many rules match.

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

ChatWorkspacePage

#
struct ChatWorkspacePage

One page of chat workspace names.

NameTypeDescription
resultsVector<str>The workspace names.
offseti64 = 0How many were skipped.
limiti64 = 0The page size.
totali64 = 0How many workspaces there are.
db-meilisearch-ChatCompletion.salam
import db.meilisearch

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

    settings := `{"source": "openAi", "apiKey": "sk-your-key", "prompts": {"system": "You answer questions about our movie catalog."}}`
    println meilisearch.UpdateChatSettings(c, "support", settings, err)
    println meilisearch.GetChatSettings(c, "support", err)
    ws := meilisearch.ListChatWorkspaces(c, 0, 20, err)
    println ws.total, ws.offset, ws.limit
    each name in ws.results:
        println name, meilisearch.GetChatWorkspace(c, name, err)
    end

    request := `{"model": "gpt-4o-mini", "stream": true, "messages": [{"role": "user", "content": "Which space movies do you have?"}]}`
    println meilisearch.ChatCompletion(c, "support", request, err)
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
    end
    println meilisearch.ResetChatSettings(c, "support", err)
    println meilisearch.DeleteChatWorkspace(c, "support", err)
end

Webhook

#
struct Webhook

A webhook: a URL Meilisearch calls each time a task finishes.

NameTypeDescription
uuidstr = ""Its id.
urlstr = ""The URL called.
headersstr = ""The headers sent with each call, as raw JSON; secret values come back hidden.
is_editablebool = falseIt can be changed; webhooks set from the command line cannot.
db-meilisearch-CreateWebhook.salam
import db.meilisearch

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

    hook := meilisearch.CreateWebhook(
        c, "https://example.com/meilisearch-hook", `{"Authorization": "Bearer hook-secret"}`, err
    )
    if not meilisearch.Ok(err):
        println meilisearch.ErrorString(err)
        ret
    end
    println hook.uuid, hook.url, hook.headers, hook.is_editable
    println meilisearch.GetWebhook(c, hook.uuid, err).url
    println meilisearch.UpdateWebhook(c, hook.uuid, "https://example.com/v2/hook", "", err).url
    each w in meilisearch.ListWebhooks(c, err):
        println w.uuid, w.url
    end
    println meilisearch.DeleteWebhook(c, hook.uuid, err)
end

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.
fieldsVector<str>Return only these fields.
filterstr = ""A filter expression, or a JSON array of them; the fields must be filterable.
idsVector<str>Return only these documents.
sortVector<str>Sort rules such as year:desc; the fields must be sortable.
retrieve_vectorsbool = falseAlso return the stored vectors.
use_networkbool = falseAsk every instance of a sharded network.
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)

    tagged := meilisearch.WithMetadata(c, "import-2026-10-16")
    opts := meilisearch.DocumentOptions {
        content_type = "application/x-ndjson",
        update = true,
        primary_key = "id",
        csv_delimiter = "",
        skip_creation = true
    }
    meilisearch.Wait(
        c,
        meilisearch.AddDocumentsWith(tagged, "movies", "{\"id\": 1, \"year\": 2016}\n", opts, err),
        err
    )
    println meilisearch.GetDocumentWith(
        c,
        "movies",
        "1",
        meilisearch.DocumentsQuery { retrieve_vectors = true, use_network = false },
        err
    )
end

DocumentOptions

#
struct DocumentOptions

How AddDocumentsWith sends documents.

NameTypeDescription
content_typestr = ""application/json (the default), application/x-ndjson or text/csv.
updatebool = falseMerge into existing documents instead of replacing them.
primary_keystr = ""The primary key, when the index does not have one yet.
csv_delimiterstr = ""The CSV delimiter; empty means a comma.
skip_creationbool = falseOnly change documents that already exist; new ids are ignored.

The example for this item is shown with the ones above: db-meilisearch-AddDocuments.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.
custom_metadatastr = ""The metadata the write was tagged with.
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.batch_strategy,
            one.details,
            one.stats,
            one.progress,
            one.duration,
            one.started_at,
            one.finished_at
    end

    println t.custom_metadata, t.network, info.custom_metadata
    println meilisearch.GetTaskDocuments(c, info.task_uid, err)
    comp := meilisearch.CompactTasks(c, err)
    println comp.status, comp.pre_size, comp.post_size, comp.action_required, comp.error_message
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.
custom_metadatastr = ""The metadata the write was tagged with.
networkstr = ""Where the task came from in a sharded network, as raw JSON.

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
uidsVector<i64>Only these tasks.
batch_uidsVector<i64>Only tasks of these batches.
canceled_byVector<i64>Only tasks canceled by these tasks.
statusesVector<str>Only these statuses.
typesVector<str>Only these task types.
index_uidsVector<str>Only 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

TaskCompaction

#
struct TaskCompaction

The result of compacting the task queue.

NameTypeDescription
statusstr = ""The outcome.
pre_sizestr = ""The size before.
post_sizestr = ""The size after.
action_requiredstr = ""What you must do next; Meilisearch asks for a restart.
error_messagestr = ""Why it failed, if it did.

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

TaskPage

#
struct TaskPage

One page of tasks.

NameTypeDescription
resultsVector<Task>The 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.
batch_strategystr = ""Why the tasks were grouped this way.
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
resultsVector<Batch>The 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

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.
timeout_msint = 0Give up on a request after this many milliseconds with the code timeout; 0 waits as long as it takes.
metadatastr = ""Text attached as customMetadata to every document write; it comes back on the task.

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
resultsVector<str>Each 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

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

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

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

Functions

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

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

CompactIndex

#
func CompactIndex(c: Client, uid: str, err &: Error): TaskInfo

Rewrites an index to give back disk space after many deletes.

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

ListFields

#
func ListFields(c: Client, uid: str, q: FieldsQuery, err &: Error): FieldPage

The fields of an index and what each is used for.

The example for this item is shown with the ones above: db-meilisearch-CreateIndex.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

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

SetStderrLogs

#
func SetStderrLogs(c: Client, target: str, err &: Error): bool

Changes what the server logs to its console, such as info or milli=debug; needs the logsRoute feature.

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

NetworkControl

#
func NetworkControl(c: Client, change: str, err &: Error): str

Sends a network control message between instances of a sharded network, as raw JSON.

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

RenderTemplate

#
func RenderTemplate(c: Client, query: str, err &: Error): str

Renders a document template or an embedder fragment and returns the result as raw JSON, to check a template before you use it; needs the renderRoute feature.

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

Search

#
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

ListSearchRules

#
func ListSearchRules(c: Client, q: SearchRuleQuery, err &: Error): SearchRulePage

A page of dynamic search rules. Rules need the dynamicSearchRules feature.

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

UpdateSearchRule

#
func UpdateSearchRule(c: Client, uid: str, rule: str, err &: Error): TaskInfo

Creates a rule or changes the parts you pass, as a JSON object.

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

DeleteSearchRule

#
func DeleteSearchRule(c: Client, uid: str, err &: Error): TaskInfo

Deletes a rule.

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

DeleteAllSearchRules

#
func DeleteAllSearchRules(c: Client, err &: Error): TaskInfo

Deletes every rule.

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

ListChatWorkspaces

#
func ListChatWorkspaces(c: Client, offset: int, limit: int, err &: Error): ChatWorkspacePage

The chat workspaces. Chats need the chatCompletions feature.

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

GetChatWorkspace

#
func GetChatWorkspace(c: Client, workspace: str, err &: Error): str

One workspace, as raw JSON.

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

DeleteChatWorkspace

#
func DeleteChatWorkspace(c: Client, workspace: str, err &: Error): bool

Deletes a workspace and its settings.

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

GetChatSettings

#
func GetChatSettings(c: Client, workspace: str, err &: Error): str

The settings of a workspace, as raw JSON; the API key comes back hidden.

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

UpdateChatSettings

#
func UpdateChatSettings(c: Client, workspace: str, settings: str, err &: Error): str

Changes the LLM source, key and prompts of a workspace, creating it when needed.

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

ResetChatSettings

#
func ResetChatSettings(c: Client, workspace: str, err &: Error): str

Puts the settings of a workspace back to the defaults.

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

ChatCompletion

#
func ChatCompletion(c: Client, workspace: str, request: str, err &: Error): str

Asks the workspace a question in the OpenAI chat format. Meilisearch searches your indexes for the answer; with "stream": true the whole stream of data: lines comes back at once.

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

ListWebhooks

#
func ListWebhooks(c: Client, err &: Error): Vector<Webhook>

Every webhook.

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

CreateWebhook

#
func CreateWebhook(c: Client, url: str, headers: str, err &: Error): Webhook

Adds a webhook; headers is a JSON object or empty.

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

UpdateWebhook

#
func UpdateWebhook(c: Client, uuid: str, url: str, headers: str, err &: Error): Webhook

Changes the URL or headers of a webhook; empty values are left as they are.

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

DeleteWebhook

#
func DeleteWebhook(c: Client, uuid: str, err &: Error): bool

Deletes a webhook.

The example for this item is shown with the ones above: db-meilisearch-CreateWebhook.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

AddDocumentsWith

#
func AddDocumentsWith(c: Client, uid: str, documents: str, o: DocumentOptions, err &: Error): TaskInfo

Adds or updates documents with every option, such as skip_creation.

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

GetDocumentWith

#
func GetDocumentWith(c: Client, uid: str, id: str, q: DocumentsQuery, err &: Error): str

One document with the fields, vectors and network options of a DocumentsQuery.

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

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

GetTaskDocuments

#
func GetTaskDocuments(c: Client, uid: i64, err &: Error): str

The documents a queued or running task will add, as NDJSON; finished tasks give task_file_not_found. Needs the getTaskDocumentsRoute feature.

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

CompactTasks

#
func CompactTasks(c: Client, err &: Error): TaskCompaction

Shrinks the task queue on disk. The server refuses writes until you restart it, as action_required says. Needs the taskQueueCompactionRoute feature.

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

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)

    meilisearch.Wait(
        c,
        meilisearch.UpdateForeignKeys(
            c, "movies", `[{"foreignIndexUid": "actors", "fieldName": "actor_ids"}]`, err
        ),
        err
    )
    println meilisearch.GetForeignKeys(c, "movies", err)
    meilisearch.Wait(c, meilisearch.ResetForeignKeys(c, "movies", err), 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

GetForeignKeys

#
func GetForeignKeys(c: Client, uid: str, err &: Error): str

Returns the foreign keys that join this index to others, as a JSON array; needs the foreignKeys feature.

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

UpdateForeignKeys

#
func UpdateForeignKeys(c: Client, uid: str, value: str, err &: Error): TaskInfo

Sets the foreign keys that join this index to others, as a JSON array; needs the foreignKeys feature.

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

ResetForeignKeys

#
func ResetForeignKeys(c: Client, uid: str, err &: Error): TaskInfo

Resets the foreign keys that join this index to others, as a JSON array; needs the foreignKeys feature to the default.

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

New

#
func New(host: str, api_key: str): Client

Makes a client. A missing http:// is added and a trailing slash is dropped; a path after the host, such as https://example.com/search behind a proxy, is kept as a prefix of every route.

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

WithTimeout

#
func WithTimeout(c: Client, timeout_ms: int): Client

A copy of the client that stops waiting after the given milliseconds.

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

WithMetadata

#
func WithMetadata(c: Client, metadata: str): Client

A copy of the client that tags every document write with this metadata, to find the tasks of one import later.

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