Skip to content

Meilisearch JS / index / Meilisearch

Class: Meilisearch

Defined in: src/meilisearch.ts:60

Constructors

Constructor

new Meilisearch(config): Meilisearch

Defined in: src/meilisearch.ts:81

Creates new Meilisearch instance

Parameters

config

Config

Configuration object

Returns

Meilisearch

Properties

config

config: Config

Defined in: src/meilisearch.ts:61


httpRequest

httpRequest: HttpRequests

Defined in: src/meilisearch.ts:62

Accessors

batches

Get Signature

get batches(): BatchClient

Defined in: src/meilisearch.ts:70

Returns

BatchClient


tasks

Get Signature

get tasks(): TaskClient

Defined in: src/meilisearch.ts:65

Returns

TaskClient

Methods

addRemote()

addRemote(options): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:531

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:566

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:304

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:731

Creates a dump

Returns

EnqueuedTaskPromise

Promise returning object of the enqueued task


createIndex()

createIndex(uid, options?): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:169

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:638

Create one API key

Parameters

options

KeyCreation

Key options

Returns

Promise<Key>

Promise returning a key


createSnapshot()

createSnapshot(): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:746

Creates a snapshot

Returns

EnqueuedTaskPromise

Promise returning object of the enqueued task


createWebhook()

createWebhook(webhook): Promise<Webhook>

Defined in: src/meilisearch.ts:406

Create a webhook

Parameters

webhook

WebhookCreatePayload

Webhook to create

Returns

Promise<Webhook>

Promise returning the created webhook


deleteDynamicSearchRule()

deleteDynamicSearchRule(uid): Promise<void>

Defined in: src/meilisearch.ts:373

Delete a dynamic search rule

Parameters

uid

string

Dynamic search rule UID

Returns

Promise<void>

Promise returning void


deleteIndex()

deleteIndex(uid): EnqueuedTaskPromise

Defined in: src/meilisearch.ts:190

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:201

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:665

Delete one API key

Parameters

keyOrUid

string

Key

Returns

Promise<void>


deleteWebhook()

deleteWebhook(uuid): Promise<void>

Defined in: src/meilisearch.ts:433

Delete a webhook

Parameters

uuid

string

Webhook UUID

Returns

Promise<void>

Promise returning void


getChatWorkspaces()

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

Defined in: src/meilisearch.ts:313

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:344

Get a dynamic search rule

Parameters

uid

string

Dynamic search rule UID

Returns

Promise<SearchRule>

Promise returning the dynamic search rule


getDynamicSearchRules()

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

Defined in: src/meilisearch.ts:329

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


getExperimentalFeatures()

getExperimentalFeatures(): Promise<RuntimeTogglableFeatures>

Defined in: src/meilisearch.ts:782

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:114

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:137

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:626

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:605

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:494

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:127

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:153

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:705

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:718

Get the version of Meilisearch

Returns

Promise<Version>

Promise returning object with version details


getWebhook()

getWebhook(uuid): Promise<Webhook>

Defined in: src/meilisearch.ts:396

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:386

Get all webhooks

Returns

Promise<ResultsWrapper<Webhook[]>>

Promise returning an object with webhooks


health()

health(): Promise<Health>

Defined in: src/meilisearch.ts:678

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:103

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:508

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:687

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:278

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:548

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:584

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:768

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:223

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): Promise<SearchRule>

Defined in: src/meilisearch.ts:357

Update a dynamic search rule

Parameters

uid

string

Dynamic search rule UID

rule

SearchRuleUpdatePayload

Dynamic search rule to update

Returns

Promise<SearchRule>

Promise returning the updated dynamic search rule


updateExperimentalFeatures()

updateExperimentalFeatures(runtimeTogglableFeatures): Promise<RuntimeTogglableFeatures>

Defined in: src/meilisearch.ts:789

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:180

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:652

Update one API key

Parameters

keyOrUid

string

Key

options

KeyUpdate

Key options

Returns

Promise<Key>

Promise returning a key


updateWebhook()

updateWebhook(uuid, webhook): Promise<Webhook>

Defined in: src/meilisearch.ts:417

Update a webhook

Parameters

uuid

string

Webhook UUID

webhook

WebhookUpdatePayload

Webhook to update

Returns

Promise<Webhook>

Promise returning the updated webhook