Skip to content

Meilisearch JS / index / Meilisearch

Class: Meilisearch

Defined in: src/meilisearch.ts:61

Constructors

Constructor

new Meilisearch(config): Meilisearch

Defined in: src/meilisearch.ts:82

Creates new Meilisearch instance

Parameters

config

Config

Configuration object

Returns

Meilisearch

Properties

config

config: Config

Defined in: src/meilisearch.ts:62


httpRequest

httpRequest: HttpRequests

Defined in: src/meilisearch.ts:63

Accessors

batches

Get Signature

get batches(): BatchClient

Defined in: src/meilisearch.ts:71

Returns

BatchClient


tasks

Get Signature

get tasks(): TaskClient

Defined in: src/meilisearch.ts:66

Returns

TaskClient

Methods

addRemote()

addRemote(options): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:578

Experimental

Add a remote to the network. Must be called on the leader instance.

https://www.meilisearch.com/docs/reference/api/network#update-the-network-object

Parameters

options

AddRemoteOptions

Options containing the remote name and configuration

Returns

EnqueuedTaskPromise

Promise returning the enqueued task


addRemotesToShard()

addRemotesToShard(shardName, remotes): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:613

Experimental

Add remotes to a shard. Must be called on the leader instance.

https://www.meilisearch.com/docs/reference/api/network#update-the-network-object

Parameters

shardName

string

Name of the shard to update

remotes

string[]

Remotes to add

Returns

EnqueuedTaskPromise

Promise returning the enqueued task


chat()

chat(workspace): ChatWorkspace

Defined in: src/meilisearch.ts:305

Get a chat workspace instance

Parameters

workspace

string

The chat workspace UID

Returns

ChatWorkspace

Instance of ChatWorkspace


createDump()

createDump(): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:778

Creates a dump

Returns

EnqueuedTaskPromise

Promise returning object of the enqueued task


createIndex()

createIndex(uid, options?): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:170

Create a new index

Parameters

uid

string

The index UID

options?

IndexOptions

Index options

Returns

EnqueuedTaskPromise

Promise returning Index instance


createKey()

createKey(options): Promise<Key>

Defined in: src/meilisearch.ts:685

Create one API key

Parameters

options

KeyCreation

Key options

Returns

Promise<Key>

Promise returning a key


createSnapshot()

createSnapshot(): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:793

Creates a snapshot

Returns

EnqueuedTaskPromise

Promise returning object of the enqueued task


createWebhook()

createWebhook(webhook): Promise<Webhook>

Defined in: src/meilisearch.ts:430

Create a webhook

Parameters

webhook

WebhookCreatePayload

Webhook to create

Returns

Promise<Webhook>

Promise returning the created webhook


deleteAllDynamicSearchRules()

deleteAllDynamicSearchRules(): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:395

Experimental

Delete all dynamic search rules

Returns

EnqueuedTaskPromise

Promise returning an enqueued task

See

https://www.meilisearch.com/docs/reference/api/search-rules/delete-a-search-rule


deleteDynamicSearchRule()

deleteDynamicSearchRule(uid): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:382

Experimental

Delete a dynamic search rule

Parameters

uid

string

Dynamic search rule UID

Returns

EnqueuedTaskPromise

Promise returning an enqueued task

See

https://www.meilisearch.com/docs/reference/api/search-rules/delete-a-search-rule


deleteIndex()

deleteIndex(uid): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:191

Delete an index

Parameters

uid

string

The index UID

Returns

EnqueuedTaskPromise

Promise which resolves when index is deleted successfully


deleteIndexIfExists()

deleteIndexIfExists(uid): Promise<boolean>

Defined in: src/meilisearch.ts:202

Deletes an index if it already exists.

Parameters

uid

string

The index UID

Returns

Promise<boolean>

Promise which resolves to true when index exists and is deleted successfully, otherwise false if it does not exist


deleteKey()

deleteKey(keyOrUid): Promise<void>

Defined in: src/meilisearch.ts:712

Delete one API key

Parameters

keyOrUid

string

Key

Returns

Promise<void>


deleteWebhook()

deleteWebhook(uuid): Promise<void>

Defined in: src/meilisearch.ts:457

Delete a webhook

Parameters

uuid

string

Webhook UUID

Returns

Promise<void>

Promise returning void


getChatWorkspaces()

getChatWorkspaces(): Promise<ResourceResults<object[]>>

Defined in: src/meilisearch.ts:314

Get all chat workspaces

Returns

Promise<ResourceResults<object[]>>

Promise returning an array of chat workspaces UIDs


getDynamicSearchRule()

getDynamicSearchRule(uid): Promise<SearchRule>

Defined in: src/meilisearch.ts:349

Experimental

Get a dynamic search rule

Parameters

uid

string

Dynamic search rule UID

Returns

Promise<SearchRule>

Promise returning the dynamic search rule

See

https://www.meilisearch.com/docs/reference/api/search-rules/get-a-search-rule


getDynamicSearchRules()

getDynamicSearchRules(parameters?): Promise<ResourceResults<SearchRule[]>>

Defined in: src/meilisearch.ts:332

Experimental

Get all dynamic search rules

Parameters

parameters?

SearchRuleListPayload

Parameters to browse dynamic search rules

Returns

Promise<ResourceResults<SearchRule[]>>

Promise returning an object with dynamic search rules

See

https://www.meilisearch.com/docs/reference/api/search-rules/list-search-rules


getExperimentalFeatures()

getExperimentalFeatures(): Promise<RuntimeTogglableFeatures>

Defined in: src/meilisearch.ts:829

https://www.meilisearch.com/docs/reference/api/experimental_features#get-all-experimental-features

Returns

Promise<RuntimeTogglableFeatures>


getIndex()

getIndex<T>(indexUid): Promise<Index<T>>

Defined in: src/meilisearch.ts:115

Gather information about an index by calling Meilisearch and return an Index instance with the gathered information

Type Parameters

T

T extends RecordAny = RecordAny

Parameters

indexUid

string

The index UID

Returns

Promise<Index<T>>

Promise returning Index instance


getIndexes()

getIndexes(parameters?): Promise<IndexesResults<Index<RecordAny>[]>>

Defined in: src/meilisearch.ts:138

Get all the indexes as Index instances.

Parameters

parameters?

Pagination

Parameters to browse the indexes

Returns

Promise<IndexesResults<Index<RecordAny>[]>>

Promise returning array of raw index information


getKey()

getKey(keyOrUid): Promise<Key>

Defined in: src/meilisearch.ts:673

Get one API key

Parameters

keyOrUid

string

Key or uid of the API key

Returns

Promise<Key>

Promise returning a key


getKeys()

getKeys(parameters?): Promise<KeysResults>

Defined in: src/meilisearch.ts:652

Get all API keys

Parameters

parameters?

Pagination

Parameters to browse the indexes

Returns

Promise<KeysResults>

Promise returning an object with keys


getNetwork()

getNetwork(): Promise<Network>

Defined in: src/meilisearch.ts:518

Experimental

Get the current network configuration.

https://www.meilisearch.com/docs/reference/api/network#get-the-network-object

Returns

Promise<Network>


getRawIndex()

getRawIndex(indexUid): Promise<IndexObject>

Defined in: src/meilisearch.ts:128

Gather information about an index by calling Meilisearch and return the raw JSON response

Parameters

indexUid

string

The index UID

Returns

Promise<IndexObject>

Promise returning index information


getRawIndexes()

getRawIndexes(parameters?): Promise<IndexesResults<IndexObject[]>>

Defined in: src/meilisearch.ts:154

Get all the indexes in their raw value (no Index instances).

Parameters

parameters?

Pagination

Parameters to browse the indexes

Returns

Promise<IndexesResults<IndexObject[]>>

Promise returning array of raw index information


getStats()

getStats(): Promise<Stats>

Defined in: src/meilisearch.ts:752

Get the stats of all the database

Returns

Promise<Stats>

Promise returning object of all the stats


getVersion()

getVersion(): Promise<Version>

Defined in: src/meilisearch.ts:765

Get the version of Meilisearch

Returns

Promise<Version>

Promise returning object with version details


getWebhook()

getWebhook(uuid): Promise<Webhook>

Defined in: src/meilisearch.ts:420

Get a webhook

Parameters

uuid

string

Webhook UUID

Returns

Promise<Webhook>

Promise returning the webhook


getWebhooks()

getWebhooks(): Promise<ResultsWrapper<Webhook[]>>

Defined in: src/meilisearch.ts:410

Get all webhooks

Returns

Promise<ResultsWrapper<Webhook[]>>

Promise returning an object with webhooks


health()

health(): Promise<Health>

Defined in: src/meilisearch.ts:725

Checks if the server is healthy, otherwise an error will be thrown.

Returns

Promise<Health>

Promise returning an object with health details


index()

index<T>(indexUid): Index<T>

Defined in: src/meilisearch.ts:104

Return an Index instance

Type Parameters

T

T extends RecordAny = RecordAny

Parameters

indexUid

string

The index UID

Returns

Index<T>

Instance of Index


initializeNetwork()

initializeNetwork(options): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:555

Experimental

Initialize a network with sharding enabled. This sets up the current instance as the leader and configures the initial set of remotes.

https://www.meilisearch.com/docs/reference/api/network#update-the-network-object

Parameters

options

InitializeNetworkOptions

Network initialization options

Returns

EnqueuedTaskPromise

Promise returning the enqueued task


isHealthy()

isHealthy(): Promise<boolean>

Defined in: src/meilisearch.ts:734

Checks if the server is healthy, return true or false.

Returns

Promise<boolean>

Promise returning a boolean


multiSearch()

multiSearch<T1, T2>(queries, extraRequestInit?): Promise<MultiSearchResponseOrSearchResponse<T1, T2>>

Defined in: src/meilisearch.ts:279

Perform multiple search queries.

It is possible to make multiple search queries on the same index or on different ones. With network feature enabled, you can also search across remote instances.

Type Parameters

T1

T1 extends MultiSearchParams | FederatedMultiSearchParams

T2

T2 extends RecordAny = RecordAny

Parameters

queries

T1

Search queries

extraRequestInit?

ExtraRequestInit

Additional request configuration options

Returns

Promise<MultiSearchResponseOrSearchResponse<T1, T2>>

Promise containing the search responses

Example

ts
client.multiSearch({
  queries: [
    { indexUid: "movies", q: "wonder" },
    { indexUid: "books", q: "flower" },
  ],
});

// Federated search with remote instance (requires network feature enabled)
client.multiSearch({
  federation: {},
  queries: [
    {
      indexUid: "movies",
      q: "wonder",
      federationOptions: {
        remote: "meilisearch instance name",
      },
    },
    {
      indexUid: "movies",
      q: "wonder",
      federationOptions: {
        remote: "meilisearch instance name",
      },
    },
  ],
});

See

https://www.meilisearch.com/docs/learn/multi_search/implement_sharding#perform-a-search


removeRemote()

removeRemote(options): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:595

Experimental

Remove a remote from the network. Must be called on the leader instance.

https://www.meilisearch.com/docs/reference/api/network#update-the-network-object

Parameters

options

RemoveRemoteOptions

Options containing the remote name to remove

Returns

EnqueuedTaskPromise

Promise returning the enqueued task


removeRemotesFromShard()

removeRemotesFromShard(shardName, remotes): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:631

Experimental

Remove remotes from a shard. Must be called on the leader instance.

https://www.meilisearch.com/docs/reference/api/network#update-the-network-object

Parameters

shardName

string

Name of the shard to update

remotes

string[]

Remotes to remove

Returns

EnqueuedTaskPromise

Promise returning the enqueued task


renderTemplate()

renderTemplate(params): Promise<RenderTemplateResponse>

Defined in: src/meilisearch.ts:815

Experimental

Render a template by injecting the given input.

This is an experimental feature. Enable the renderRoute experimental feature via Meilisearch.updateExperimentalFeatures before calling it.

Parameters

params

RenderTemplateParams

Template/fragment to render and the input to inject

Returns

Promise<RenderTemplateResponse>

Promise returning the unrendered template and the rendered result

See

https://www.meilisearch.com/docs/reference/api/template/render-documents-with-post


swapIndexes()

swapIndexes(params): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:224

Swaps a list of index tuples.

Parameters

params

IndexSwap[]

List of indexes tuples to swap.

Returns

EnqueuedTaskPromise

Promise returning object of the enqueued task


updateDynamicSearchRule()

updateDynamicSearchRule(uid, rule): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:364

Experimental

Update a dynamic search rule

Parameters

uid

string

Dynamic search rule UID

rule

SearchRuleUpdatePayload

Dynamic search rule to update

Returns

EnqueuedTaskPromise

Promise returning an enqueued task

See

https://www.meilisearch.com/docs/reference/api/search-rules/create-or-update-a-search-rule


updateExperimentalFeatures()

updateExperimentalFeatures(runtimeTogglableFeatures): Promise<RuntimeTogglableFeatures>

Defined in: src/meilisearch.ts:836

https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features

Parameters

runtimeTogglableFeatures

RuntimeTogglableFeatures

Returns

Promise<RuntimeTogglableFeatures>


updateIndex()

updateIndex(uid, options?): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:181

Update an index

Parameters

uid

string

The index UID

options?

IndexOptions

Index options to update

Returns

EnqueuedTaskPromise

Promise returning Index instance after updating


updateKey()

updateKey(keyOrUid, options): Promise<Key>

Defined in: src/meilisearch.ts:699

Update one API key

Parameters

keyOrUid

string

Key

options

KeyUpdate

Key options

Returns

Promise<Key>

Promise returning a key


updateNetwork()

updateNetwork(options): Promise<EnqueuedTask | Network>

Defined in: src/meilisearch.ts:536

Experimental

Update the network configuration. Must be called on the leader instance when a leader is configured.

When a leader is set, returns an enqueued networkTopologyChange task. When clearing the leader (or when no leader is set), returns the updated network object synchronously.

https://www.meilisearch.com/docs/reference/api/network#update-the-network-object

Parameters

options

UpdateNetworkOptions

Network update options

Returns

Promise<EnqueuedTask | Network>

Promise returning an enqueued task, or the updated network object


updateWebhook()

updateWebhook(uuid, webhook): Promise<Webhook>

Defined in: src/meilisearch.ts:441

Update a webhook

Parameters

uuid

string

Webhook UUID

webhook

WebhookUpdatePayload

Webhook to update

Returns

Promise<Webhook>

Promise returning the updated webhook