Meilisearch JS / index / Index
Class: Index<T>
Defined in: src/indexes.ts:68
Type Parameters
T
T extends RecordAny = RecordAny
Constructors
Constructor
new Index<
T>(config,uid,primaryKey?):Index<T>
Defined in: src/indexes.ts:82
Parameters
config
Request configuration options
uid
string
UID of the index
primaryKey?
string
Primary Key of the index
Returns
Index<T>
Properties
createdAt
createdAt:
Date|undefined
Defined in: src/indexes.ts:71
httpRequest
httpRequest:
HttpRequests
Defined in: src/indexes.ts:73
primaryKey
primaryKey:
string|undefined
Defined in: src/indexes.ts:70
tasks
tasks:
TaskClient
Defined in: src/indexes.ts:74
uid
uid:
string
Defined in: src/indexes.ts:69
updatedAt
updatedAt:
Date|undefined
Defined in: src/indexes.ts:72
Methods
addDocuments()
addDocuments(
documents,options?):EnqueuedTaskPromise
Defined in: src/indexes.ts:366
Add or replace multiples documents to an index
Parameters
documents
T[]
Array of Document objects to add/replace
options?
Options on document addition
Returns
Promise containing an EnqueuedTask
addDocumentsFromString()
addDocumentsFromString(
documents,contentType,queryParams?):EnqueuedTaskPromise
Defined in: src/indexes.ts:384
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
Content type of your document: 'text/csv'|'application/x-ndjson'|'application/json'
queryParams?
Returns
Promise containing an EnqueuedTask
addDocumentsInBatches()
addDocumentsInBatches(
documents,batchSize?,options?):EnqueuedTaskPromise[]
Defined in: src/indexes.ts:405
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
options?
Options on document addition
Returns
Promise containing array of enqueued task objects for each batch
delete()
delete():
EnqueuedTaskPromise
Defined in: src/indexes.ts:277
Delete an index.
Returns
Promise which resolves when index is deleted successfully
deleteAllDocuments()
deleteAllDocuments(
options?):EnqueuedTaskPromise
Defined in: src/indexes.ts:537
Delete all documents of an index
Parameters
options?
Returns
Promise containing an EnqueuedTask
deleteDocument()
deleteDocument(
documentId,options?):EnqueuedTaskPromise
Defined in: src/indexes.ts:493
Delete one document
Parameters
documentId
string | number
Id of Document to delete
options?
Task enqueue options (e.g. customMetadata)
Returns
Promise containing an EnqueuedTask
deleteDocuments()
deleteDocuments(
params,options?):EnqueuedTaskPromise
Defined in: src/indexes.ts:514
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
options?
Returns
Promise containing an EnqueuedTask
fetchInfo()
fetchInfo():
Promise<Index<T>>
Defined in: src/indexes.ts:221
Fetch and update Index information.
Returns
Promise<Index<T>>
Promise to the current Index object with updated information
fetchPrimaryKey()
fetchPrimaryKey():
Promise<string|undefined>
Defined in: src/indexes.ts:231
Get Primary Key.
Returns
Promise<string | undefined>
Promise containing the Primary Key of the index
getChat()
getChat():
Promise<ChatSettings>
Defined in: src/indexes.ts:1457
Get the index's chat settings.
Returns
Promise<ChatSettings>
Promise containing a ChatSettings object
getDictionary()
getDictionary():
Promise<string[]>
Defined in: src/indexes.ts:1140
Get the dictionary settings of a Meilisearch index.
Returns
Promise<string[]>
Promise containing the dictionary settings
getDisplayedAttributes()
getDisplayedAttributes():
Promise<string[]>
Defined in: src/indexes.ts:939
Get the displayed-attributes
Returns
Promise<string[]>
Promise containing array of displayed-attributes
getDistinctAttribute()
getDistinctAttribute():
Promise<DistinctAttribute>
Defined in: src/indexes.ts:772
Get the distinct-attribute
Returns
Promise<DistinctAttribute>
Promise containing the distinct-attribute of the index
getDocument()
getDocument<
D>(documentId,parameters?):Promise<D>
Defined in: src/indexes.ts:345
Get one document
Type Parameters
D
D extends RecordAny = T
Parameters
documentId
string | number
Document ID
parameters?
Parameters applied on a document
Returns
Promise<D>
Promise containing Document response
getDocuments()
getDocuments<
D>(params?):Promise<ResourceResults<D[]>>
Defined in: src/indexes.ts:310
Get documents of an index.
Type Parameters
D
D extends RecordAny = T
Parameters
params?
Parameters to browse the documents. Parameters can contain the filter field only available in Meilisearch v1.2 and newer, and the sort field available in Meilisearch v1.16 and newer
Returns
Promise<ResourceResults<D[]>>
Promise containing the returned documents
getEmbedders()
getEmbedders():
Promise<Embedders>
Defined in: src/indexes.ts:1221
Get the embedders settings of a Meilisearch index.
Returns
Promise<Embedders>
Promise containing the embedders settings
getFaceting()
getFaceting():
Promise<Faceting>
Defined in: src/indexes.ts:1021
Get the faceting settings.
Returns
Promise<Faceting>
Promise containing object of faceting index settings
getFacetSearch()
getFacetSearch():
Promise<boolean>
Defined in: src/indexes.ts:1379
Get the facet search settings.
Returns
Promise<boolean>
Promise containing object of facet search settings
getFields()
getFields(
params?,extraRequestInit?):Promise<FieldsResults>
Defined in: src/indexes.ts:1489
Retrieve fields from an index with optional filtering and pagination. This endpoint allows you to query fields based on their properties (searchable, filterable, displayed, sortable, distinct, rankingRule, and localized).
Parameters
params?
Query parameters including pagination and filter options
extraRequestInit?
Additional request configuration options
Returns
Promise<FieldsResults>
Promise containing the fields results with pagination info
getFilterableAttributes()
getFilterableAttributes():
Promise<FilterableAttributes>
Defined in: src/indexes.ts:813
Get the filterable-attributes
Returns
Promise<FilterableAttributes>
Promise containing an array of filterable-attributes
getForeignKeys()
getForeignKeys():
Promise<ForeignKey[]>
Defined in: src/indexes.ts:1340
Get the foreign keys settings.
Returns
Promise<ForeignKey[]>
Promise containing an array of foreign key settings
getLocalizedAttributes()
getLocalizedAttributes():
Promise<LocalizedAttributes>
Defined in: src/indexes.ts:1299
Get the localized attributes settings.
Returns
Promise<LocalizedAttributes>
Promise containing object of localized attributes settings
getNonSeparatorTokens()
getNonSeparatorTokens():
Promise<string[]>
Defined in: src/indexes.ts:1099
Get the list of all non-separator tokens.
Returns
Promise<string[]>
Promise containing array of non-separator tokens
getPagination()
getPagination():
Promise<PaginationSettings>
Defined in: src/indexes.ts:615
Get the pagination settings.
Returns
Promise<PaginationSettings>
Promise containing object of pagination settings
getPrefixSearch()
getPrefixSearch():
Promise<PrefixSearch>
Defined in: src/indexes.ts:1418
Get the prefix search settings.
Returns
Promise<PrefixSearch>
Promise containing object of prefix search settings
getProximityPrecision()
getProximityPrecision():
Promise<ProximityPrecision>
Defined in: src/indexes.ts:1179
Get the proximity precision settings of a Meilisearch index.
Returns
Promise<ProximityPrecision>
Promise containing the proximity precision settings
getRankingRules()
getRankingRules():
Promise<string[]>
Defined in: src/indexes.ts:732
Get the list of all ranking-rules
Returns
Promise<string[]>
Promise containing array of ranking-rules
getRawInfo()
getRawInfo():
Promise<IndexObject>
Defined in: src/indexes.ts:206
Get index information.
Returns
Promise<IndexObject>
Promise containing index information
getSearchableAttributes()
getSearchableAttributes():
Promise<string[]>
Defined in: src/indexes.ts:897
Get the searchable-attributes
Returns
Promise<string[]>
Promise containing array of searchable-attributes
getSearchCutoffMs()
getSearchCutoffMs():
Promise<SearchCutoffMs>
Defined in: src/indexes.ts:1260
Get the SearchCutoffMs settings.
Returns
Promise<SearchCutoffMs>
Promise containing object of SearchCutoffMs settings
getSeparatorTokens()
getSeparatorTokens():
Promise<string[]>
Defined in: src/indexes.ts:1060
Get the list of all separator tokens.
Returns
Promise<string[]>
Promise containing array of separator tokens
getSettings()
getSettings():
Promise<Settings>
Defined in: src/indexes.ts:576
Retrieve all settings
Returns
Promise<Settings>
Promise containing Settings object
getSortableAttributes()
getSortableAttributes():
Promise<string[]>
Defined in: src/indexes.ts:855
Get the sortable-attributes
Returns
Promise<string[]>
Promise containing array of sortable-attributes
getStats()
getStats():
Promise<IndexStats>
Defined in: src/indexes.ts:292
Get stats of an index
Returns
Promise<IndexStats>
Promise containing object with stats of the index
getStopWords()
getStopWords():
Promise<string[]>
Defined in: src/indexes.ts:693
Get the list of all stop-words
Returns
Promise<string[]>
Promise containing array of stop-words
getSynonyms()
getSynonyms():
Promise<Record<string,string[]>>
Defined in: src/indexes.ts:654
Get the list of all synonyms
Returns
Promise<Record<string, string[]>>
Promise containing record of synonym mappings
getTypoTolerance()
getTypoTolerance():
Promise<TypoTolerance>
Defined in: src/indexes.ts:981
Get the typo tolerance settings.
Returns
Promise<TypoTolerance>
Promise containing the typo tolerance settings.
resetDictionary()
resetDictionary():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1164
Reset the dictionary settings to its default value
Returns
Promise containing an EnqueuedTask
resetDisplayedAttributes()
resetDisplayedAttributes():
EnqueuedTaskPromise
Defined in: src/indexes.ts:966
Reset the displayed-attributes.
Returns
Promise containing an EnqueuedTask
resetDistinctAttribute()
resetDistinctAttribute():
EnqueuedTaskPromise
Defined in: src/indexes.ts:798
Reset the distinct-attribute.
Returns
Promise containing an EnqueuedTask
resetEmbedders()
resetEmbedders():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1245
Reset the embedders settings to its default value
Returns
Promise containing an EnqueuedTask
resetFaceting()
resetFaceting():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1045
Reset the faceting settings.
Returns
Promise containing an EnqueuedTask
resetFacetSearch()
resetFacetSearch():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1403
Reset the facet search settings.
Returns
Promise containing an EnqueuedTask
resetFilterableAttributes()
resetFilterableAttributes():
EnqueuedTaskPromise
Defined in: src/indexes.ts:840
Reset the filterable-attributes.
Returns
Promise containing an EnqueuedTask
resetForeignKeys()
resetForeignKeys():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1364
Reset the foreign keys settings.
Returns
Promise containing an EnqueuedTask
resetLocalizedAttributes()
resetLocalizedAttributes():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1325
Reset the localized attributes settings.
Returns
Promise containing an EnqueuedTask
resetNonSeparatorTokens()
resetNonSeparatorTokens():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1125
Reset the non-separator tokens list to its default value
Returns
Promise containing an EnqueuedTask
resetPagination()
resetPagination():
EnqueuedTaskPromise
Defined in: src/indexes.ts:639
Reset the pagination settings.
Returns
Promise containing an EnqueuedTask
resetPrefixSearch()
resetPrefixSearch():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1442
Reset the prefix search settings.
Returns
Promise containing an EnqueuedTask
resetProximityPrecision()
resetProximityPrecision():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1206
Reset the proximity precision settings to its default value
Returns
Promise containing an EnqueuedTask
resetRankingRules()
resetRankingRules():
EnqueuedTaskPromise
Defined in: src/indexes.ts:757
Reset the ranking rules list to its default value
Returns
Promise containing an EnqueuedTask
resetSearchableAttributes()
resetSearchableAttributes():
EnqueuedTaskPromise
Defined in: src/indexes.ts:924
Reset the searchable-attributes.
Returns
Promise containing an EnqueuedTask
resetSearchCutoffMs()
resetSearchCutoffMs():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1284
Reset the SearchCutoffMs settings.
Returns
Promise containing an EnqueuedTask
resetSeparatorTokens()
resetSeparatorTokens():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1084
Reset the separator tokens list to its default value
Returns
Promise containing an EnqueuedTask
resetSettings()
resetSettings():
EnqueuedTaskPromise
Defined in: src/indexes.ts:600
Reset settings.
Returns
Promise containing an EnqueuedTask
resetSortableAttributes()
resetSortableAttributes():
EnqueuedTaskPromise
Defined in: src/indexes.ts:882
Reset the sortable-attributes.
Returns
Promise containing an EnqueuedTask
resetStopWords()
resetStopWords():
EnqueuedTaskPromise
Defined in: src/indexes.ts:717
Reset the stop-words list to be empty again
Returns
Promise containing an EnqueuedTask
resetSynonyms()
resetSynonyms():
EnqueuedTaskPromise
Defined in: src/indexes.ts:678
Reset the synonym list to be empty again
Returns
Promise containing an EnqueuedTask
resetTypoTolerance()
resetTypoTolerance():
EnqueuedTaskPromise
Defined in: src/indexes.ts:1006
Reset the typo tolerance settings.
Returns
Promise containing object of the enqueued update
search()
search<
D,S>(query?,options?,extraRequestInit?):Promise<SearchResponse<D,S>>
Defined in: src/indexes.ts:105
Search for documents into an index
Type Parameters
D
D extends RecordAny = T
S
S extends SearchParams = SearchParams
Parameters
query?
string | null
Query string
options?
S
Search options
extraRequestInit?
Returns
Promise<SearchResponse<D, S>>
Promise containing the search response
searchForFacetValues()
searchForFacetValues(
params,extraRequestInit?):Promise<SearchForFacetValuesResponse>
Defined in: src/indexes.ts:170
Search for facet values
Parameters
params
Parameters used to search on the facets
extraRequestInit?
Returns
Promise<SearchForFacetValuesResponse>
Promise containing the search response
searchGet()
searchGet<
D,S>(query?,options?,extraRequestInit?):Promise<SearchResponse<D,S>>
Defined in: src/indexes.ts:125
Search for documents into an index using the GET method
Type Parameters
D
D extends RecordAny = T
S
S extends SearchParams = SearchParams
Parameters
query?
string | null
Query string
options?
S
Search options
extraRequestInit?
Returns
Promise<SearchResponse<D, S>>
Promise containing the search response
searchSimilarDocuments()
searchSimilarDocuments<
D,S>(params):Promise<SearchResponse<D,S>>
Defined in: src/indexes.ts:187
Search for similar documents
Type Parameters
D
D extends RecordAny = T
S
S extends SearchParams = SearchParams
Parameters
params
Parameters used to search for similar documents
Returns
Promise<SearchResponse<D, S>>
Promise containing the search response
update()
update(
data?):EnqueuedTaskPromise
Defined in: src/indexes.ts:265
Update an index.
Parameters
data?
Data to update
Returns
Promise to the current Index object with updated information
updateChat()
updateChat(
chatSettings):EnqueuedTaskPromise
Defined in: src/indexes.ts:1469
Update the index's chat settings.
Parameters
chatSettings
ChatSettingsPayload object
Returns
Promise containing an EnqueuedTask
updateDictionary()
updateDictionary(
dictionary):EnqueuedTaskPromise
Defined in: src/indexes.ts:1152
Update the dictionary settings. Overwrite the old settings.
Parameters
dictionary
Array that contains the new dictionary settings.
Returns
Promise containing an EnqueuedTask or null
updateDisplayedAttributes()
updateDisplayedAttributes(
displayedAttributes):EnqueuedTaskPromise
Defined in: src/indexes.ts:952
Update the displayed-attributes.
Parameters
displayedAttributes
Array of strings that contains attributes of an index to display
Returns
Promise containing an EnqueuedTask
updateDistinctAttribute()
updateDistinctAttribute(
distinctAttribute):EnqueuedTaskPromise
Defined in: src/indexes.ts:784
Update the distinct-attribute.
Parameters
distinctAttribute
Field name of the distinct-attribute
Returns
Promise containing an EnqueuedTask
updateDocuments()
updateDocuments(
documents,options?):EnqueuedTaskPromise
Defined in: src/indexes.ts:428
Add or update multiples documents to an index
Parameters
documents
Partial<T>[]
Array of Document objects to add/update
options?
Options on document update
Returns
Promise containing an EnqueuedTask
updateDocumentsByFunction()
updateDocumentsByFunction(
options,taskOptions?):EnqueuedTaskPromise
Defined in: src/indexes.ts:556
This is an EXPERIMENTAL feature, which may break without a major version. It's available after Meilisearch v1.10.
More info about the feature: https://github.com/orgs/meilisearch/discussions/762 More info about experimental features in general: https://www.meilisearch.com/docs/reference/api/experimental-features
Parameters
options
UpdateDocumentsByFunctionOptions
Object containing the function string and related options
taskOptions?
Returns
Promise containing an EnqueuedTask
updateDocumentsFromString()
updateDocumentsFromString(
documents,contentType,queryParams?):EnqueuedTaskPromise
Defined in: src/indexes.ts:473
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
Content type of your document: 'text/csv'|'application/x-ndjson'|'application/json'
queryParams?
Options on raw document addition
Returns
Promise containing an EnqueuedTask
updateDocumentsInBatches()
updateDocumentsInBatches(
documents,batchSize?,options?):EnqueuedTaskPromise[]
Defined in: src/indexes.ts:447
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
options?
Options on document update
Returns
Promise containing array of enqueued task objects for each batch
updateEmbedders()
updateEmbedders(
embedders):EnqueuedTaskPromise
Defined in: src/indexes.ts:1233
Update the embedders settings. Overwrite the old settings.
Parameters
embedders
Object that contains the new embedders settings.
Returns
Promise containing an EnqueuedTask or null
updateFaceting()
updateFaceting(
faceting):EnqueuedTaskPromise
Defined in: src/indexes.ts:1033
Update the faceting settings.
Parameters
faceting
Faceting index settings object
Returns
Promise containing an EnqueuedTask
updateFacetSearch()
updateFacetSearch(
facetSearch):EnqueuedTaskPromise
Defined in: src/indexes.ts:1391
Update the facet search settings.
Parameters
facetSearch
boolean
Boolean value
Returns
Promise containing an EnqueuedTask
updateFilterableAttributes()
updateFilterableAttributes(
filterableAttributes):EnqueuedTaskPromise
Defined in: src/indexes.ts:826
Update the filterable-attributes.
Parameters
filterableAttributes
Array of strings containing the attributes that can be used as filters at query time
Returns
Promise containing an EnqueuedTask
updateForeignKeys()
updateForeignKeys(
foreignKeys):EnqueuedTaskPromise
Defined in: src/indexes.ts:1352
Update the foreign keys settings.
Parameters
foreignKeys
Foreign keys array
Returns
Promise containing an EnqueuedTask
updateLocalizedAttributes()
updateLocalizedAttributes(
localizedAttributes):EnqueuedTaskPromise
Defined in: src/indexes.ts:1311
Update the localized attributes settings.
Parameters
localizedAttributes
Localized attributes object
Returns
Promise containing an EnqueuedTask
updateNonSeparatorTokens()
updateNonSeparatorTokens(
nonSeparatorTokens):EnqueuedTaskPromise
Defined in: src/indexes.ts:1111
Update the list of non-separator tokens. Overwrite the old list.
Parameters
nonSeparatorTokens
Array that contains non-separator tokens.
Returns
Promise containing an EnqueuedTask or null
updatePagination()
updatePagination(
pagination):EnqueuedTaskPromise
Defined in: src/indexes.ts:627
Update the pagination settings.
Parameters
pagination
Pagination object
Returns
Promise containing an EnqueuedTask
updatePrefixSearch()
updatePrefixSearch(
prefixSearch):EnqueuedTaskPromise
Defined in: src/indexes.ts:1430
Update the prefix search settings.
Parameters
prefixSearch
PrefixSearch value
Returns
Promise containing an EnqueuedTask
updateProximityPrecision()
updateProximityPrecision(
proximityPrecision):EnqueuedTaskPromise
Defined in: src/indexes.ts:1192
Update the proximity precision settings. Overwrite the old settings.
Parameters
proximityPrecision
String that contains the new proximity precision settings.
Returns
Promise containing an EnqueuedTask or null
updateRankingRules()
updateRankingRules(
rankingRules):EnqueuedTaskPromise
Defined in: src/indexes.ts:745
Update the list of ranking-rules. Overwrite the old list.
Parameters
rankingRules
Array that contain ranking rules sorted by order of importance.
Returns
Promise containing an EnqueuedTask
updateSearchableAttributes()
updateSearchableAttributes(
searchableAttributes):EnqueuedTaskPromise
Defined in: src/indexes.ts:910
Update the searchable-attributes.
Parameters
searchableAttributes
Array of strings that contains searchable attributes sorted by order of importance(most to least important)
Returns
Promise containing an EnqueuedTask
updateSearchCutoffMs()
updateSearchCutoffMs(
searchCutoffMs):EnqueuedTaskPromise
Defined in: src/indexes.ts:1272
Update the SearchCutoffMs settings.
Parameters
searchCutoffMs
Object containing SearchCutoffMsSettings
Returns
Promise containing an EnqueuedTask
updateSeparatorTokens()
updateSeparatorTokens(
separatorTokens):EnqueuedTaskPromise
Defined in: src/indexes.ts:1072
Update the list of separator tokens. Overwrite the old list.
Parameters
separatorTokens
Array that contains separator tokens.
Returns
Promise containing an EnqueuedTask or null
updateSettings()
updateSettings(
settings):EnqueuedTaskPromise
Defined in: src/indexes.ts:588
Update all settings Any parameters not provided will be left unchanged.
Parameters
settings
Object containing parameters with their updated values
Returns
Promise containing an EnqueuedTask
updateSortableAttributes()
updateSortableAttributes(
sortableAttributes):EnqueuedTaskPromise
Defined in: src/indexes.ts:868
Update the sortable-attributes.
Parameters
sortableAttributes
Array of strings containing the attributes that can be used to sort search results at query time
Returns
Promise containing an EnqueuedTask
updateStopWords()
updateStopWords(
stopWords):EnqueuedTaskPromise
Defined in: src/indexes.ts:705
Update the list of stop-words. Overwrite the old list.
Parameters
stopWords
Array of strings that contains the stop-words.
Returns
Promise containing an EnqueuedTask
updateSynonyms()
updateSynonyms(
synonyms):EnqueuedTaskPromise
Defined in: src/indexes.ts:666
Update the list of synonyms. Overwrite the old list.
Parameters
synonyms
Mapping of synonyms with their associated words
Returns
Promise containing an EnqueuedTask
updateTypoTolerance()
updateTypoTolerance(
typoTolerance):EnqueuedTaskPromise
Defined in: src/indexes.ts:994
Update the typo tolerance settings.
Parameters
typoTolerance
Object containing the custom typo tolerance settings.
Returns
Promise containing object of the enqueued update
create()
staticcreate(uid,options?,config):EnqueuedTaskPromise
Defined in: src/indexes.ts:244
Create an index.
Parameters
uid
string
Unique identifier of the Index
options?
IndexOptions = {}
Index options
config
Request configuration options
Returns
Newly created Index object