Class Index<T>

Type Parameters

  • T extends Record<string, any> = Record<string, any>

Constructors

  • Type Parameters

    • T extends Record<string, any> = Record<string, any>

    Parameters

    • config: Config

      Request configuration options

    • uid: string

      UID of the index

    • Optional primaryKey: string

      Primary Key of the index

    Returns Index<T>

Properties

createdAt: undefined | Date
httpRequest: HttpRequests
primaryKey: undefined | string
tasks: TaskClient
uid: string
updatedAt: undefined | Date

Methods

  • Add or replace multiples documents to an index

    Parameters

    • documents: T[]

      Array of Document objects to add/replace

    • Optional options: DocumentOptions

      Options on document addition

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Add or replace multiples documents in a string format to an index. It only supports csv, ndjson and json formats.

    Parameters

    • documents: string

      Documents provided in a string to add/replace

    • contentType: ContentType

      Content type of your document: 'text/csv'|'application/x-ndjson'|'application/json'

    • Optional queryParams: RawDocumentAdditionOptions

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Add or replace multiples documents to an index in batches

    Parameters

    • documents: T[]

      Array of Document objects to add/replace

    • batchSize: number = 1000

      Size of the batch

    • Optional options: DocumentOptions

      Options on document addition

    Returns Promise<EnqueuedTask[]>

    Promise containing array of enqueued task objects for each batch

  • Delete one document

    Parameters

    • documentId: string | number

      Id of Document to delete

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Delete multiples documents of an index.

    Parameters

    • params: DocumentsDeletionQuery | DocumentsIds

      Params value can be:

      • DocumentsDeletionQuery: An object containing the parameters to customize your document deletion. Only available in Meilisearch v1.2 and newer
      • DocumentsIds: An array of document ids to delete

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Fetch and update Index information.

    Returns Promise<Index<T>>

    Promise to the current Index object with updated information

  • Get Primary Key.

    Returns Promise<undefined | string>

    Promise containing the Primary Key of the index

  • Get the dictionary settings of a Meilisearch index.

    Returns Promise<string[]>

    Promise containing the dictionary settings

  • Get the displayed-attributes

    Returns Promise<string[]>

    Promise containing array of displayed-attributes

  • Get the distinct-attribute

    Returns Promise<null | string>

    Promise containing the distinct-attribute of the index

  • Get one document

    Type Parameters

    • D extends Record<string, any> = T

    Parameters

    • documentId: string | number

      Document ID

    • Optional parameters: DocumentQuery<T>

      Parameters applied on a document

    Returns Promise<D>

    Promise containing Document response

  • Get documents of an index.

    Type Parameters

    • D extends Record<string, any> = T

    Parameters

    • parameters: DocumentsQuery<D> = {}

      Parameters to browse the documents. Parameters can contain the filter field only available in Meilisearch v1.2 and newer

    Returns Promise<ResourceResults<D[]>>

    Promise containing the returned documents

  • Get the filterable-attributes

    Returns Promise<string[]>

    Promise containing an array of filterable-attributes

  • Get the list of all non-separator tokens.

    Returns Promise<string[]>

    Promise containing array of non-separator tokens

  • Get the list of all ranking-rules

    Returns Promise<string[]>

    Promise containing array of ranking-rules

  • Get the searchable-attributes

    Returns Promise<string[]>

    Promise containing array of searchable-attributes

  • Get the list of all separator tokens.

    Returns Promise<string[]>

    Promise containing array of separator tokens

  • Get the sortable-attributes

    Returns Promise<string[]>

    Promise containing array of sortable-attributes

  • Get the list of all stop-words

    Returns Promise<string[]>

    Promise containing array of stop-words

  • Get the list of all synonyms

    Returns Promise<object>

    Promise containing object of synonym mappings

  • Get one task of the index.

    Parameters

    • taskUid: number

      Task identifier

    Returns Promise<Task>

    Promise containing a task

  • Search for documents into an index

    Type Parameters

    Parameters

    • Optional query: null | string

      Query string

    • Optional options: S

      Search options

    • Optional config: Partial<Request>

      Additional request configuration options

    Returns Promise<SearchResponse<D, S>>

    Promise containing the search response

  • Search for documents into an index using the GET method

    Type Parameters

    Parameters

    • Optional query: null | string

      Query string

    • Optional options: S

      Search options

    • Optional config: Partial<Request>

      Additional request configuration options

    Returns Promise<SearchResponse<D, S>>

    Promise containing the search response

  • Update the dictionary settings. Overwrite the old settings.

    Parameters

    • dictionary: Dictionary

      Array that contains the new dictionary settings.

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask or null

  • Update the displayed-attributes.

    Parameters

    • displayedAttributes: DisplayedAttributes

      Array of strings that contains attributes of an index to display

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Add or update multiples documents to an index

    Parameters

    • documents: Partial<T>[]

      Array of Document objects to add/update

    • Optional options: DocumentOptions

      Options on document update

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Add or update multiples documents in a string format to an index. It only supports csv, ndjson and json formats.

    Parameters

    • documents: string

      Documents provided in a string to add/update

    • contentType: ContentType

      Content type of your document: 'text/csv'|'application/x-ndjson'|'application/json'

    • Optional queryParams: RawDocumentAdditionOptions

      Options on raw document addition

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Add or update multiples documents to an index in batches

    Parameters

    • documents: Partial<T>[]

      Array of Document objects to add/update

    • batchSize: number = 1000

      Size of the batch

    • Optional options: DocumentOptions

      Options on document update

    Returns Promise<EnqueuedTask[]>

    Promise containing array of enqueued task objects for each batch

  • Update the embedders settings. Overwrite the old settings.

    Parameters

    • embedders: Embedders

      Object that contains the new embedders settings.

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask or null

  • Update the filterable-attributes.

    Parameters

    • filterableAttributes: FilterableAttributes

      Array of strings containing the attributes that can be used as filters at query time

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Update the list of non-separator tokens. Overwrite the old list.

    Parameters

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask or null

  • Update the proximity precision settings. Overwrite the old settings.

    Parameters

    • proximityPrecision: ProximityPrecision

      String that contains the new proximity precision settings.

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask or null

  • Update the list of ranking-rules. Overwrite the old list.

    Parameters

    • rankingRules: RankingRules

      Array that contain ranking rules sorted by order of importance.

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Update the searchable-attributes.

    Parameters

    • searchableAttributes: SearchableAttributes

      Array of strings that contains searchable attributes sorted by order of importance(most to least important)

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Update the list of separator tokens. Overwrite the old list.

    Parameters

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask or null

  • Update all settings Any parameters not provided will be left unchanged.

    Parameters

    • settings: Settings

      Object containing parameters with their updated values

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Update the sortable-attributes.

    Parameters

    • sortableAttributes: SortableAttributes

      Array of strings containing the attributes that can be used to sort search results at query time

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Update the list of stop-words. Overwrite the old list.

    Parameters

    • stopWords: StopWords

      Array of strings that contains the stop-words.

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Update the list of synonyms. Overwrite the old list.

    Parameters

    • synonyms: Synonyms

      Mapping of synonyms with their associated words

    Returns Promise<EnqueuedTask>

    Promise containing an EnqueuedTask

  • Update the typo tolerance settings.

    Parameters

    • typoTolerance: TypoTolerance

      Object containing the custom typo tolerance settings.

    Returns Promise<EnqueuedTask>

    Promise containing object of the enqueued update

  • Wait for a task to be processed.

    Parameters

    • taskUid: number

      Task identifier

    • waitOptions: WaitOptions = {}

      Options on timeout and interval

    Returns Promise<Task>

    Promise containing an array of tasks

  • Wait for multiple tasks to be processed.

    Parameters

    • taskUids: number[]

      Tasks identifier

    • waitOptions: WaitOptions = {}

      Options on timeout and interval

    Returns Promise<Task[]>

    Promise containing an array of tasks